歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Dev-C++創建使用類(Class)工程舉例

Dev-C++創建使用類(Class)工程舉例

日期:2017/3/1 9:59:36   编辑:Linux編程

打開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 <iostream>
#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;
}

Copyright © Linux教程網 All Rights Reserved