Dev-C++创建使用类(Class)工程举例

2014-11-24 07:46:09 · 作者: · 浏览: 2

打开Dev-C++后,按如下操作创建工程:


File->New->Project 得到如下窗口:选择Console Application (如果你想做GUI界面程序请选择Windows Application)



创建好后,新建文件(Ctrl+n),一定要选择添加到工程(得到以下窗口选择Yes就行了),否则编译会出错的(链接出错,我试过了)。



一般一个工程如果有类的话,至少应该有main.cpp和xxx.cpp和xxx.h 这三个文件其中xxx为类文件名:


我的如下:


main.cpp


//main.cpp
#include
#include "demo.h"


/* run this program using the console pauser or add your own getch, system("pause") or input loop */


int main(int argc, char *argv[]) {
demo foo1(0);
foo1.show();
return 1;
}