[問題]產生的錯誤訊息
想請問一下,我有三個檔案,分別是basketball.h,basketball_class.cpp,
還有player.cpp,程式如下
basketball.h檔程式碼:
class nba
{
private:
char name[20];
bool haveplace;
public:
nba(char *fn="none",bool place=0);
void Shownba();
}
basketball_class.cpp檔程式碼:
#include<iostream>
#include<cstring>
using namespace std;
#include "basketball.h"
nba::nba(char *fn,bool place)
{
strcpy(name,fn);
haveplace=place;
}
void nba::Shownba()
{
cout<<"Hello "<<name<<", wellcome to here , now we";
if(haveplace)
cout<<"has place \n";
else
cout<<"has't place \n";
}
player.cpp程式碼:
#include<iostream>
using namespace std;
#include "basketball.h"
int main()
{
nba player("James",1);
player.Shownba();
system("pause");
}
我用一個資料夾放這三個檔案,然後用一個project載入這三個檔,然後編譯,
但是程式出現一個錯誤訊息new type may not be defined in a return type
,想了半天不懂他的意思,這個訊息的位址是在basketball_class的第六行,
我用dev-c++編譯的,各位大大能告訴我錯在哪嗎?這種要連結的檔案有時候我還會
出現link error,若出現這類訊息,大都是哪裡錯誤阿?另外我看書上寫.h
檔大都要加入#ifdefine....
#define......
.
statement
.
.
#endif
加入這個有什麼涵義嗎?拍謝,小弟問題有點多,麻煩請各位大大幫忙。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.70.182.200
→
11/20 16:37, , 1F
11/20 16:37, 1F
→
11/20 16:38, , 2F
11/20 16:38, 2F
→
11/20 16:38, , 3F
11/20 16:38, 3F
→
11/20 16:41, , 4F
11/20 16:41, 4F
→
11/20 16:44, , 5F
11/20 16:44, 5F
→
11/20 16:45, , 6F
11/20 16:45, 6F
→
11/20 16:45, , 7F
11/20 16:45, 7F
推
11/20 16:48, , 8F
11/20 16:48, 8F
→
11/20 16:58, , 9F
11/20 16:58, 9F
→
11/20 17:02, , 10F
11/20 17:02, 10F
→
11/20 17:03, , 11F
11/20 17:03, 11F
→
11/20 17:07, , 12F
11/20 17:07, 12F
→
11/20 17:27, , 13F
11/20 17:27, 13F
→
11/20 17:28, , 14F
11/20 17:28, 14F
→
11/20 17:29, , 15F
11/20 17:29, 15F
→
11/20 17:30, , 16F
11/20 17:30, 16F
→
11/20 20:51, , 17F
11/20 20:51, 17F
→
11/20 20:54, , 18F
11/20 20:54, 18F