views:

2766

answers:

1

Hi all,

I am developing a small app under Linux using the CodeBlocks IDE. I have defined a class with the following code:

class CRenderContext
{
public:     /*instance methods*/
             CRenderContext() :
             m_iWidth(0), m_iHeight(0),
             m_iX(0), m_iY(0),
             m_bFullScreen(false), m_bShowPointer(false) {};

             CRenderContext  (int                    iWidth,
                              int                    iHeight,
                              int                    iX,
                              int                    iY,
                              bool                   bFullScreen,
                              bool                   bShowPointer)
                              :
                              m_iWidth(iWidth), m_iHeight(iHeight),
                              m_iX(iX), m_iY(iY),
                              m_bFullScreen(bFullScreen), m_bShowPointer(bShowPointer) {};
        virtual ~CRenderContext () {};

    public:     /*instance data*/
        int     m_iWidth;
        int     m_iHeight;
        int     m_iX;
        int     m_iY;
        bool    m_bFullScreen;
        bool    m_bShowPointer;
};

I always get the following error when compiling the above code:

error: expected '=', ',', ';', 'asm' or 'attribute' before CRenderContext

Any ideas about how to solve the error?

Thanks in advance,

Eugenio

+4  A: 

You are compiling it as C code, not C++. You probably need to rename the source file to have a .cpp extension. The code compiles perfectly (as C++) with g++ and comeau, although you have some superfluous semicolons. For example:

virtual ~CRenderContext () {};

No need for the semicolon ot the end there.

anon