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.
自己定义构造函数,系统默认的构造函数就没有作用了。
#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++ primer 习题 15
- c++ primer 习题 15
- c++ primer 习题 15
- 《C++ Primer》第五版课后习题解答_第五章(3)(15-19)
- 《C++ Primer》第五版课后习题解答_第六章(2)(08-15)
- C++ primer 习题8-3 15 16
- C++ Primer(第五版)读书笔记 & 习题解答 --- Chapter 3
- C++ Primer 第9章 习题9.32
- C++ Primer 第9章 习题9.41
- C++ Primer 第10章 习题10.23
- C++ Primer 第10章 习题10.38
- C++ Primer 第11章 习题11.9
- C++ Primer 第4章 习题4.34
- 《C++ Primer》习题9.20的问题
- C++ primer习题笔记第4章
- Python-习题11~15
- C++ primer 习题笔记第5~6章
- C++ Primer(第四版) 课后习题3.14 vector单词转大写
- C++ Primer 笔记+习题解答(五)
- 《C++ Primer 4 Answer Book》 整理[15]——第16章 模板与泛型编程