#include <iostream>
using namespace std;
//类声明
class A;
//类定义
class A
{
int m; //数据成员声明
int f1(); //成员函数声明
int f2(); //成员函数声明及定义,类实现
{
return 1;
}
};
//类实现
int A::f1()
{
return 0;
}
int main()
{
A a; //类使用,实例化类
return 0;
}
to sum up:
- Class declaration (forward declaration). For a class, previously defined after it declares that it is an incomplete type. It can only be used to define a reference and a pointer to it, or incomplete statement types as parameters or function return values.
- Class definition. Objects can only be created after the class definition, the class member access. When the class is considered completed when the class is defined, i.e., a member of the class declaration, the class itself is an incomplete type, it is not the type of data members of the class type, but may be a class type of a reference or pointer.
- Class implementation. Is a property class data members, member functions of the class method. Implementation class that is implemented or defined member functions.
- Class use. The use of classes, i.e. the various operations to the class object is performed.