您的位置:首页 > 编程语言 > C语言/C++

c++ primer 习题 15

2010-06-11 10:35 176 查看
环境 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.

自己定义构造函数,系统默认的构造函数就没有作用了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c++ c