[問題] 有關標頭檔和實作內容分開
看板C_and_CPP (C/C++)作者davies1828 (little white)時間15年前 (2011/02/09 12:38)推噓1(1推 0噓 17→)留言18則, 4人參與討論串1/1
看著書上跟著寫兩個小程式
這個是.h檔
#include <string>
using std::string;
class GradeBook
{
public:
GradeBook(string);
void setCourseName(string);
string getCourseName();
void displayMessage();
private:
string courseName;
};
這個是實作的檔案
#include <iostream>
#include "GradeBook.h"
using std::cout;
using std::endl;
GradeBook::GradeBook(string name)
{
setCourseName(name);
}
void GradeBook::setCourseName(string name)
{
courseName = name;
}
string GradeBook::getCourseName()
{
return courseName;
}
void GradeBook::displayMessage()
{
cout << "Welcome to the gradebook for\n" <<getCourseName()
<< " !! " << endl;
}
可當我compile的時候他出現
undefined reference to `WinMain@16'
我有把.h跟c++檔放在同一個目錄
但是他好像沒有找到的感覺
我用的是code blocks
煩請各位前輩指正一下
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.62.188.234
→
02/09 12:39, , 1F
02/09 12:39, 1F
→
02/09 12:40, , 2F
02/09 12:40, 2F
→
02/09 12:41, , 3F
02/09 12:41, 3F
→
02/09 13:01, , 4F
02/09 13:01, 4F
推
02/09 13:15, , 5F
02/09 13:15, 5F
→
02/09 13:15, , 6F
02/09 13:15, 6F
→
02/09 13:26, , 7F
02/09 13:26, 7F
→
02/09 13:29, , 8F
02/09 13:29, 8F
→
02/09 13:30, , 9F
02/09 13:30, 9F
→
02/09 13:34, , 10F
02/09 13:34, 10F
→
02/09 13:35, , 11F
02/09 13:35, 11F
→
02/09 13:35, , 12F
02/09 13:35, 12F
→
02/09 13:37, , 13F
02/09 13:37, 13F
→
02/09 13:42, , 14F
02/09 13:42, 14F
→
02/09 19:27, , 15F
02/09 19:27, 15F
→
02/09 19:28, , 16F
02/09 19:28, 16F
→
02/09 19:28, , 17F
02/09 19:28, 17F
→
02/09 19:45, , 18F
02/09 19:45, 18F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章