问题 填空题

以下程序的输出结果是 【8】 
    #include<iostream.h>
    class object
     private:
       int va1;
      public:
       object( );
       object(int i)
       ~object( ); ;
    object::Object( )
     va1=0;
      cout < < "Default constructor for object" < < end1;
    object::object(int i)
     va1=i
      cout < < "Constructor for object" < < va1 < < end1;
    object::~object( )
     cout < < "Destructor for object" < < va1 < < end1;
    class container  private:
               object one;
                object two;
                int data;
               public:
                container( );
                container(int i,int j,int k);
                ~container( ); ;
    container::container( )
     data=0;
      cout < < "Default constructor for container" < < end1;
    container::container(int i,int j,int k):two(i),one(j)
     data=k;
      cout < < "Constructor for container" < < end1;
    container::~container( )
     cout < < "Destructor for container" < < end1;
    void main( )
     container anObj(5,6,10);

答案

参考答案:(8)【8】Constructor for object6
    Constructor for object5
    Constructor for container
    Destructor for container
    Destructor for object5
    Destructor for object6

解析:解析:C++语言中的构造函数和析构函数分别是在声明对象时和对象调用完毕后调用,本题中的调用就是这样成对出现的。

单项选择题
问答题 简答题