我收到以下错误:
1> resistor.cpp(7): error C2084: function 'Resistor::Resistor(int,std::string,double,int [])' already has a body
1> resistor.h(25) : see previous definition of '{ctor}'
对于我的每一个类函数,即使在电阻器.h 中我没有任何空实现:
电阻器.h:
class Resistor
{
private:
int rIndex;
double resistance; // resistance (in Ohms)
string name; // C++ string holding the label
int endpointNodeIDs[2]; // IDs of nodes it attaches to
public:
Resistor(int rIndex_,string name_,double resistance_,int endpoints_[2]);
}
电阻器.cpp:
Resistor::Resistor(int rIndex_,string name_,double resistance_,int endpoints_[2])
{
if (nodeArray[endpoints_[0]].addResistor(rIndex_) && NodeArray[endpoints_[1]].addResistor(rIndex_))
{
rIndex = rIndex_;
name = name_;
resistance = resistance_;
endpointNodeIDs[0] = endpoints_[0];
endpointNodeIDs[1] = endpoints_[1];
}
return;
}
等我的每个班级功能
有谁能够帮我?
ps我还收到以下错误,再次针对电阻器类中的每个函数(构造函数除外,神秘地):
1>rparser.cpp(301): error C2264: 'Resistor::setIndex' : error in function definition or declaration; function not called