自定义类的问题
自定义的类:
example.h
#ifndef exampleH
#define exampleH
//---------------------------------------------------------------------------
class Example
{
private: int i;
public: void SetData(int n);
int GetData();
Example();
~Example();
}
#endif
example.cpp
#pragma hdrstop
#include "example.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
void Example::SetData(int n)
{
i=n;
}
int Example::GetData()
{
return i;
}
编译的时候提示错误:
[C++ Error] example.cpp(13): E2176 Too many types in declaration
[C++ Error] example.cpp(14): E2111 Type 'Example' may not be defined here
[C++ Error] example.cpp(14): E2316 'Example::SetData(int)' is not a member of 'Example'
我刚学bcb,请各位高手指点