c++ primer 习题 15

来源:互联网 发布:中石化发布页岩气数据 编辑:程序博客网 时间:2024/05/22 06:25

环境 dec c++

 

#include <conio.h>

#include <iostream.h>

#include <string>

 

class temp

{

      public:

             temp(int n){cout<<"this is test /n";}     

             ~temp(){}

};

 

int main()

{

    temp a;

    getch();

    return 0;    

}

 

会报错。把 temp(int n=20) {cout<<"this is test /n";}   就不会了,因为 没有参数的时候  默认n=20.

自己定义构造函数,系统默认的构造函数就没有作用了。