于钥吧 关注:8贴子:83
  • 1回复贴,共1

www.yuyuenimabi.com

只看楼主收藏回复

#include”iostream.h”
C1ass CCouter

int value;
public:
CCounter();
CCounter(int val);
~CCounter();
};
class CExample

intvalue;
public:
CCounter car;
CExample();
cexample(int val);
void DISplay();
~CExample();
};
CCounter::CCounter()

cout<<”ccounter Constructorl”<<endl;
value=o;

CCounter::CCounter(int val)

cout<<”CCounter constructor2”<<endl;
value=val;

CCounter::~CCounter()

cout<<”CCounter Destructor”<<endl;

CExarnple::CExample()
{
cout<<”CExample constructorl”<<endl;
value=0;

CExample::CExample(int val)

cout<<”CExamPle Constructorl”<<endl;
value=val;

void CExample::Display()
{
cout<<”value=” <<value<<endl;

CExample::~CExample()
{
cout<<”CExample Destructor”<<endl;

void main()

CExample e(2);
e.Display();

答:ccounter Constructor2
CExample Constructor2
Value=2;
CExample Destmctor
CCoullter Destructor
14.以下程序运行的结果为。
#include<iostream.h>
Class B

public:
B(){};
B(int i , int j);
void Printb ();
private:
int a,b;
};
classA

public:
A(){};
A(int i,int j);
void printa();
private:
B C;
};
A::A(int i,int D):c(i,j)
{ };
void A::printa()

c.printb();

B::B(int i,int j)
{
a=i;b=j;

void B:: printb()
{
cout <<”a=” <<a<<”,b=” <<b <<endl;

void main()

A m(7’8);
m.printa();


IP属地:四川1楼2014-12-29 22:01回复


    IP属地:四川2楼2016-11-17 16:19
    回复