Y
Yudan YI \(OSU\)
Hi
I have a problem with the overloading operators. My code is followed
header file
class TObsData
{
public:
string stnname_
double obs_;
~TObsData() {};
TObsData();
TObsData(const TObsData& obsDataSrc);
TObsData& operator= (const TObsData& obsDataSrc);
friend ostream& operator<<(ostream& os, const TObsData& obsDataSrc);
TObsSD operator- (const TObsData& obsDataSrc); // <= I want to
define an operator - and the result is another
// object of 2nd class defined later
...
}
class TObsSD
{
public:
TObsData obs_[2]; // the class contain the definition for the 1st
class
...
}
then i define the overload operator- for the TObsData class in the *.cpp
file
TObsSD TObsData:perator- (const TObsData& obsDataSrc)
{
TObsSD obsSD;
obsSD.obs_[0] = *this;
obsSD.obs_[1] = obsDataSrc;
return (obsSD);
}
a error will shown at "TObsSD operator- (const TObsData& obsDataSrc); "
when I try to complie the project
do you guy know what cause this problem?
Thanks
Yudan
I have a problem with the overloading operators. My code is followed
header file
class TObsData
{
public:
string stnname_
double obs_;
~TObsData() {};
TObsData();
TObsData(const TObsData& obsDataSrc);
TObsData& operator= (const TObsData& obsDataSrc);
friend ostream& operator<<(ostream& os, const TObsData& obsDataSrc);
TObsSD operator- (const TObsData& obsDataSrc); // <= I want to
define an operator - and the result is another
// object of 2nd class defined later
...
}
class TObsSD
{
public:
TObsData obs_[2]; // the class contain the definition for the 1st
class
...
}
then i define the overload operator- for the TObsData class in the *.cpp
file
TObsSD TObsData:perator- (const TObsData& obsDataSrc)
{
TObsSD obsSD;
obsSD.obs_[0] = *this;
obsSD.obs_[1] = obsDataSrc;
return (obsSD);
}
a error will shown at "TObsSD operator- (const TObsData& obsDataSrc); "
when I try to complie the project
do you guy know what cause this problem?
Thanks
Yudan