CRenderContext 之前预期的 asm 或 __attribute__
我正在 Linux 下使用 CodeBlocks IDE 开发一个小应用程序。 我用以下代码定义了一个类:
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;
};
编译上述代码时,我总是收到以下错误:
error: Expected '=', ',', ';', 'asm' or 'attribute' before CRenderContext
关于如何执行的任何想法解决错误?
预先感谢,
尤金尼奥
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将其编译为 C 代码,而不是 C++。 您可能需要重命名源文件以具有 .cpp 扩展名。 尽管有一些多余的分号,但该代码可以使用 g++ 和 comeau 完美编译(作为 C++)。 例如:
末尾不需要分号。
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:
No need for the semicolon ot the end there.