博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
6_1const对象运用的错误
阅读量:7096 次
发布时间:2019-06-28

本文共 686 字,大约阅读时间需要 2 分钟。

/** 程序的版权和版本声明部分* Copyright (c)2012, 烟台大学计算机学院学生* All rightsreserved.* 文件名称: object.cpp* 作者:纪子龙* 完成日期: 2013年4 月 4 日* 版本号: v1.0* 输入描述:无* 问题描述:无* 程序输出:无*/#include
#include
using namespace std;class C{private: int x;public: C(int x){this->x = x;} int getX() {return x;}};int main(){ const C c(5); cout<
#include
using namespace std;class C{private: int x;public: C(int x){this->x = x;} int getX() {return x;}};int main(){ C c(5);//将c定义为非const对象 cout<
#include
using namespace std;class C{private: int x;public: C(int x){this->x = x;} int getX() const{return x;}//将getX定义为const成员函数};int main(){ const C c(5); cout<

转载地址:http://kdxql.baihongyu.com/

你可能感兴趣的文章
JavaSE基本语法、数据类型、操作符等:int、long、Integer、Long、if、else、for、while...
查看>>
解析XML文件
查看>>
牛客练习赛46
查看>>
netty线程模型
查看>>
Codeforces Round #237 Div.2 A
查看>>
initrd.gz的解压和制作
查看>>
LeetCode:Edit Distance(字符串编辑距离DP)
查看>>
设计流程及工具记录
查看>>
关于CDialogBar的编程
查看>>
吹きすさぶ风の中で
查看>>
对象引用前加const 报错
查看>>
linux 0.11 源码学习(十一)
查看>>
编码风格——linux内核开发的coding style
查看>>
表格隔行变色案例
查看>>
IOS 模拟不同网络环境 - Network Link Conditioner
查看>>
JAVA第一周学习
查看>>
sql语句select group by order by where一般先后顺序 转载
查看>>
for循环是怎么工作的
查看>>
支付宝支付
查看>>
第三周 动态规划算法(1):1.集合加法
查看>>