我找不到我的錯誤在哪裏可以幫我嗎?預計錯誤;或}但我已經把它放在那裏我無法運行它雖然。你知道爲什麼嗎?驅動的課程關閉;儘管該程序仍然無法編譯。請指導我,謝謝一切正常,但無法運行:預期錯誤{或;
#include <iostream>
using namespace std;
class myBase{
private:
int foodmoney;
int hobbymoney;
public:
void setdata();
friend int caldata();
};
void myBase::setdata(){
cout<<"Enter foodmoney :" ;cin>>foodmoney;
cout<<"enter hoobymoney:";cin>>hobbymoney;
}
int caldata(int sum,int foodmoney,int hobbymoney){
cin>>foodmoney;
cin>>hobbymoney;
sum=(foodmoney+hobbymoney)/2;
return sum;
}
class Derivedclass:public myBase{
int moneyforfood,moneyforhobby;
public:
int setmydrived(int moneyforfood,int moneyforhobby){
cout<<"enter money for food(drived class)"<<endl;
cin>>moneyforfood;
cout<<"enter money for hobby(drived class)"<<endl;
cin>>moneyforhobby;
}
int calculatedrived(){
int sumd=(moneyforfood+moneyforhobby);
cout<<"avg money on frived class "<<sumd<<endl;
};
int main(){
myBase baseobj;
baseobj.setdata();
int caldata();
Derivedclass obj;
int setmydrived();
obj.calculatedrived();
system("puase");
}
固定用凹槽會告訴你,不** **一切是好的 – 2013-03-24 10:21:52
以'一切correct'不作任何降神的問題。 .. – 2013-03-24 10:23:32
@ user2203809正確縮進您的代碼!你現在擁有的是荒謬的。檢查這個鏈接的一些想法:[縮進樣式](http://en.wikipedia.org/wiki/Indent_style) – jrok 2013-03-24 10:25:35