C++ Topics and Explanations
Help on CTime << operator

[ Follow Ups ] [ Post Follow Up ] [ C++ Topics and Explanations ]

Posted by Mauro Fiorentino on November 30, 200 at 01:12:53:

Hi there,

I defined an Activity class. This class has got an attribute
as CTime firstStartTime.
Now if I overload the << operator for the Activity class I got an
error .
If you have an idea why this happen please, replay.
the error is :

D:\MyProjects\ActiviProva\ActiviProva.cpp(48) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class CTime' (or there is no acceptable conversion)
Error executing cl.exe.

ActiviProva.exe - 1 error(s), 0 warning(s)

here you are the code :
/*****************/
#include "stdafx.h"
#include
#include
#include
#include

#include

using namespace std;
typedef CTime TIME;

//typedef unsigned int TIME;

class Aactivity
{


friend ostream& operator<< (ostream& os, const Aactivity& A );

public:

Aactivity(){};
virtual ~Aactivity(){};

void setFirstStartTime (TIME time) {firstStartTime=time;};
void setLatestEndTime (TIME time) {latestEndTime=time;};
TIME getFirstStartTime () const {return firstStartTime;};
TIME getLatestEndTime ()const {return latestEndTime;};

protected:
TIME firstStartTime;
TIME latestEndTime;

private:


};


ostream &
operator<< (ostream & ostr, const Aactivity & A)
{


ostr << "A.firstStartTime =" << A.getFirstStartTime() << endl;
return ostr;
}

int main(int argc, char* argv[])
{

Aactivity A;

cout << A << endl;
return 0;

}

/*****************/
thanks anyway,
Mauro





Follow Ups:


Post a Follow Up:

Name:
E-Mail:

Subject:

Comments:


[ Follow Ups ] [ Post Follow Up ] [ C++ Topics and Explanations ]