第六周实验报告(1)
来源:互联网 发布:淘宝打包员有年轻人吗 编辑:程序博客网 时间:2024/04/30 00:59
*烟台大学计算机学院学生
*作者: 王 琦
*文件内容: 修改错误代码
*题目:下面的程序存在编译错误。两种方法可以修改,请给出这两种。更倾向于哪一种,处理此问题的原则是什么?
*完成时间 :2012年3月26日
原代码段:
class C{private:int x; public:C(int x){this->x = x;}int getX(){return x;}};void main(){const C c(5);cout<<c.getX();system("pause");}
1修改后:
#include<iostream>using namespace std;class C{private:int x; public:C(int x){this->x = x;}int getX() const{return x;}};void main(){ const C c(5);cout<<c.getX()<<endl;system("pause");}
2修改后:
#include<iostream>using namespace std;class C{private:int x; public:C(int x){this->x = x;}int getX() {return x;}};void main(){ C c(5);cout<<c.getX()<<endl;system("pause");}
- 第六周实验报告(1)
- 第六周实验报告(1)
- 第六周实验报告(任务1)
- 第六周C++实验报告(1)
- 第六周实验报告4(1)
- 第六周实验报告1
- 第六周实验报告1
- 第六周实验报告1
- 第六周实验报告1
- 第六周实验报告1
- 第六周实验报告1
- 第六周实验报告(1)
- 第六周实验报告1
- 第六周实验报告1
- 第六周实验报告1
- 第六周实验报告
- 《第六周实验报告任务1》
- 第六周实验报告任务1
- 手把手教你把Vim改装成一个IDE编程环境(图文)
- 索引(性能优化的重要手段)
- 第六周实验报告(三)平面坐标类
- 第六周实验报告(一)
- 第六周任务2
- 第六周实验报告(1)
- VB实验报告
- IOS开发 如何联机调试和发布程序(99$)
- 第6周实验报告2
- 关于在Eclipse里使用Weblogic9.2进行部署项目不成功的解决方法
- VB实验报告----制作随机图形,制作动画
- ostringstream函数的使用
- 队列的入队,出队,测长,打印操作 .
- create table as select性能测试