-3
我需要幫助這個錯誤?類和構造錯誤C++
molecule.cpp:31:7:錯誤:合格基準爲 '摩爾' 是一個構造名稱,而不是隻要一個構造可以聲明 摩爾::摩爾(ATOM1(),Atom2()){
一個類型class mole {
private:
string name;
int proton;
int neutron;
int electron;
int valence;
public:
int mass();
mole();
mole(Atom, Atom);
mole(string);
mole(string,int,int,int);
};
mole::mole()
{
name="hydrogen";
proton=1;
neutron=0;
electron=1;
valence=1;
}
mole::mole(Atom1(), Atom2()){
proton= Atom1.p + Atom2.p;
neutron=Atom1.n + Atom2.n;
electron=Atom1.e + Atom2.e;
}
在另一個文件中:
#include<iostream>
using namespace std;
class Atom {
private:
string name;
int proton;
int neutron;
int electron;
int valence;
public:
int mass();
Atom();
Atom(int,int,int);
Atom(string);
Atom(string,int,int,int);
};
Atom::Atom(){
name="hydrogen";
proton=1;
neutron=0;
electron=1;
valence=1;
}
Atom::Atom(int p, int n, int e){
proton=p;
neutron=n;
electron=e;
}
Atom::Atom(string n){
name=n;
}
Atom::Atom(string nm, int p, int n, int e){
name = nm;
proton=p;
neutron=n;
electron=e;
}
int Atom::mass(){
int mass = proton+neutron;
return mass;
}
哪條線是線31? –
更改:'mole :: mole(Atom1(),Atom2())' - >'mole :: mole(Atom Atom1,Atom Atom2)' –
更改'mole :: mole(Atom1(),Atom2()) {'to'mole :: mole(Atom Atom1,Atom Atom2){' – eyllanesc