class P
{
public :
P(int p1,int p2)
{
pri1=p1;
pri2=p2;
}
int inc1 ()
{
return ++pri1;
}
int inc2()
{
return ++pri2;
}
void disp ()
{
cout<<"pri1="<<pri1<<"pri2="<<pri2<<endl;
}
private :
int pri1,pri2;
};
class D1:private P
{
public :
D1(int p1,int p2,int p3):P(p1,p2)
{
pri3=p4;
}
int inc1()
{
return P::inc1();
}
int inc3()
{
return ++pri3;
}
void disp()
{
P::disp();
cout<<"pri3="<<pri3<<endl;
}
private:
int pri3;
};
class D2:public P
{
public :
D2(int p1,int p2,int p4):P(p1,p2)
}
pri4=p4;
}
int inc1 ()
{
P::inc1();
P::inc1();
return P::inc1();
int inc4()
{
return ++pri4;
}
void disp ()
{
P::disp();
cout<<"pri4="<<pri4<<endl;
}
private :
int pri4;
};
class D12 :private D1,public D2
{
public :
D12 (int p11,int p12,int p13,int p21,int p22,int p23,int p):D(p11, p12 ,p13),D(p21,p22,p23)
{
pri12=p;
}
int inc1()
{
D2::inc1();
return D2::inc1();
return D2::inc1();
}
int inc5()
{
return ++pri12;
}
void disp ()
{
cout<<"D2::disp()"<<endl;
D2::disp();
cout<<"pri12="<<pri12<<endl;
}
private:
int pri12;
};
void main ()
{
D12 d(1,2,3,4,5,6,7);
d.disp();
d.inc1();
d.inc4();
d.inc5();
d.D12::inc1();
d.disp();
}
帮忙找一下错误,再帮忙解释一下程序,我不太明白