我找不到我的错误在哪里,你能帮帮我吗?错误是预期的;或 } 但我已经把它放在那里我无法运行它。你知道为什么吗?驱动类由 ; 虽然程序仍然无法编译。请指导我谢谢
#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");
}