主题:这个怎么会错呢 刚学的希望大神能指导
#include<iostream>
using namespace std;
class Box
{public:
Box();
Box(int,int);
int v();
protected:
int gao;
int chang;
};
Box::Box(int c,int k)
{
gao=c;
chang=k;
}
int Box::v()
{return(chang*gao);
}
class Box2: public Box
{ public:
get();
get(int m,int n);
int s();
};
Box2::get(int m,int n)
{ gao=m;
chang=n;
}
int Box2::s()
{ return(chang/gao);}
int main()
{while(1){
int a,b;
cin>>a>>b;
Box b1(a,b);
cout<<b1.v();
int m,n;
cin>>m>>n;
Box2 b2(3,1);
cout<<b2.s();
}
return 0;
using namespace std;
class Box
{public:
Box();
Box(int,int);
int v();
protected:
int gao;
int chang;
};
Box::Box(int c,int k)
{
gao=c;
chang=k;
}
int Box::v()
{return(chang*gao);
}
class Box2: public Box
{ public:
get();
get(int m,int n);
int s();
};
Box2::get(int m,int n)
{ gao=m;
chang=n;
}
int Box2::s()
{ return(chang/gao);}
int main()
{while(1){
int a,b;
cin>>a>>b;
Box b1(a,b);
cout<<b1.v();
int m,n;
cin>>m>>n;
Box2 b2(3,1);
cout<<b2.s();
}
return 0;
}
E:\C++\Microsoft Visual Studio\test.cpp(41) : error C2661: 'Box2::Box2' : no overloaded function takes 2 parameters