This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Error on Member Initialization
- From: "Allen Williams" <anw at csunv dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Fri, 12 Sep 2003 20:24:13 -0400
- Subject: Error on Member Initialization
Hello,
I have the following declared:
class RADCOMMGT_API CradComMgt
{
public:
CradComMgt(CLog* Log=NULL);
~CradComMgt();
--- snip ---
};
/***************************************/
In another file I declare this:
extern CLog Log; // <- Note declaration of CLog object
class radApp : public lnDaemon
{
public:
virtual void DaemonInit();
protected:
CradComMgt m_MyServer(&Log); // <- Note initialization
};
/******************************************/
I get this from the compiler:
g++ -o radApp -D_LINUX -L../Libraries -I../Headers
radApp.cpp -lApp -lLog -lSock -lNetDataSvc -lradComMgt -lradCore
In file included from radApp.cpp:16:
radApp.h:24: error: invalid data member initialization
radApp.h:24: error: (use `=' to initialize static data members)
make: *** [radApp] Error 1
Compilation exited abnormally with code 2 at Fri Sep 12 20:04:53
I have Stroustrup's C++ reference manual and Ellis and Stroustrup's C++
Annotated reference, both of which say this should be a valid form to call
the CradComMgt::CradComMgt(CLog *) constructor. What am I doing wrong here?
Thanks in Advance,
anw