标题:急求 多继承派生程序错误!急!急
取消只看楼主
zhonglai123
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-7-23
 问题点数:0 回复次数:0 
急求 多继承派生程序错误!急!急
哪位大虾看一下我的这个程序
是关于派生类的多继承的 这个程序要是不要带参数可以运行通过
但是加上参数后就显示下面的错误 仔细查了没有错误啊为什呢
这个程序是我从教材上的抄下来的
#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
搜索更多相关主题的帖子: 程序错误 派生 继承 教材 
2008-08-13 17:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-228125-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.133612 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved