作者a77d4e06 (喵~>"<||)
看板C_and_CPP
標題[問題] 簡單錯誤卻找不到@@|
時間Wed May 12 00:57:40 2010
=====================已解決,感謝===================
以下C++
大家好,我有一個簡單的問題卻一直抓不到BUG在哪,勞煩各位幫忙,
這是描述.H的函式
#include<iostream>
#include<string>
#include "Account.h"
Account::Account(string name)
{ //一直抓不到這行的BUG
setAccount(name);
}
void Account::setAccount(string name)
{
nameofAccount =name;
}
string Account::getAccount()
{
return nameofAccount;
}
-----------------------------------------------
以下.H
#include <iostream>
#include <string>
using namespace std;
class Account
{
public:
Account(string);
string getAccount();
void setAccount(string);
void setMoney(int,int);
int getMoney();
private:
int getm;
int initial;
int money;
string nameofAccount;
}
他一直出現
new types may not be defined in a return type
return type specification for constructor invalid
在我有標記bug那行
麻煩各位高手了 感謝
※ 編輯: a77d4e06 來自: 218.35.19.53 (05/12 00:58)
→ bleed1979:srting?? 05/12 00:59
※ 編輯: a77d4e06 來自: 218.35.19.53 (05/12 01:00)
→ a77d4e06:好像不是耶>"< 05/12 01:00
→ bleed1979:class尾,分號?? 05/12 01:01
推 VictorTom:class{}後的 ; 有記得加嗎?? 05/12 01:01
→ VictorTom:被b大搶先了XDDD 05/12 01:01
→ a77d4e06:為蝦米CLASS後面要分號@@? 05/12 01:02
※ 編輯: a77d4e06 來自: 218.35.19.53 (05/12 01:03)
→ loveme00835:有的就只是語法上的規定而已, 沒有為什麼 ~"~ 05/12 01:07
推 snowlike:相較於函式括弧,個人認為分號結尾在型態宣告上相當一致 05/12 01:32
→ uranusjr:C++ class 宣告語法是承繼 C struct 來的 05/12 12:55