急求 多继承派生程序错误!急!急
哪位大虾看一下我的这个程序 是关于派生类的多继承的 这个程序要是不要带参数可以运行通过
但是加上参数后就显示下面的错误 仔细查了没有错误啊为什呢
这个程序是我从教材上的抄下来的
#include<iostream.h>
Class base1
{
Public:
base1(int i)
{
cout<<"constrcting base1"<<endl;
x1=i;
}
void print()
{cout<<"x1= "<<x1<<endl;
}
protected:
int x1;
};
class base2
{
public:
base2(int j)
{cout <<"constructing base2"<<endl;
x2=j;
}
void print()
{cout<<"x2="<<x2<<endl;
}
proteced:
int x2;
};
class base3
{
public:
base3()
{cout<<"constructing class base3"<<endl;
}
void print()
{cout<<"constructing class base3 no values"<<endl;
}
};
class M : public base1,public base2, public base3
{
public:
M(int a,int b,int c,int d):base1(a),A(c),base2(b),B(d){}
void print()
{ base1::print();
base2::print();
base3::print();
}
};
void main()
{ M obj(1,2,3,4);
obj.print();
}
显示的错误是:
error c2629: unexpected 'class M ('
error c2334: unexpected token(s) proceding ':';skipping apparent function body
error c2660: M::M :function does not take 4 paraments
[[it] 本帖最后由 zhonglai123 于 2008-8-13 17:32 编辑 [/it]]