#include <iostream.h>
class aa
{
public:
aa(int ii):i(ii){}
void setV(int ii){i = ii;}
int getV(){return i;}
private:
int i;
};
class bb
{
public:
bb(aa* app):ap(app){}
void output(){cout<<ap->getV()<<"\n";}
void setAV(int ii){ap->setV(ii);}
private:
aa * ap;
};
void main()
{
bb * bp = new bb(&aa(5)); //《=====哪位XD给分析下对错和解释下
bp->output();
bp->setAV(15);
bp->output();
delete bp;
}
谢谢。
class aa
{
public:
aa(int ii):i(ii){}
void setV(int ii){i = ii;}
int getV(){return i;}
private:
int i;
};
class bb
{
public:
bb(aa* app):ap(app){}
void output(){cout<<ap->getV()<<"\n";}
void setAV(int ii){ap->setV(ii);}
private:
aa * ap;
};
void main()
{
bb * bp = new bb(&aa(5)); //《=====哪位XD给分析下对错和解释下
bp->output();
bp->setAV(15);
bp->output();
delete bp;
}
谢谢。