由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - C++ question
相关主题
C++: 如何对const data member做assignment?C++ Q48: illegal operation (C33)
有人帮我看看这个C++class的定义为什么是合法的吗?C++ 面试题
请教一个C++问题搞不清C++里的constant expression
请教一个const和non const的C++问题请问如何准备C/C++面试
大牛来做一下这道题问个C++的题目
请教operator const char*() 的问题C++: Q75 copy constructor 问什么用 const reference?
请问一道c++题目请帮忙看道题 c++ operator overload
C++ Q29: extern and const together这小段code有什么问题吗?
相关话题的讨论汇总
话题: const话题: c++话题: int话题: function话题: constant
进入JobHunting版参与讨论
1 (共1页)
z*y
发帖数: 1311
1
const int &func (int a, int b) const;
what is the meaning of first "const" and last "const"?
what is the meaning of "&"?
d**********x
发帖数: 4083
2
...

【在 z*y 的大作中提到】
: const int &func (int a, int b) const;
: what is the meaning of first "const" and last "const"?
: what is the meaning of "&"?

H****s
发帖数: 247
3
This function returns a constant integer reference, this member function is
a constant function that won't change any member variables of the associated
class.
w**s
发帖数: 339
4
你这得从头学。
A*****i
发帖数: 3587
5
一直认为函数前的const绝对是有人故意造出来害人的,因为完全没有用处。貌似C++
prime也提过这个,但是每次面试总考,这绝对是个阴谋
l*********u
发帖数: 19053
6
同意。
return constant的function,应该是某个"蛋疼帝"想出来滴 :)

【在 A*****i 的大作中提到】
: 一直认为函数前的const绝对是有人故意造出来害人的,因为完全没有用处。貌似C++
: prime也提过这个,但是每次面试总考,这绝对是个阴谋

q****m
发帖数: 177
7
c++ overloading 不检查 return type 吧。

【在 l*********u 的大作中提到】
: 同意。
: return constant的function,应该是某个"蛋疼帝"想出来滴 :)

H****s
发帖数: 247
8
你们错了, 这里我只举一个简单例子说明一下,return constant reference
绝对不是多此一举。
class A{

Object theObj;
public:
const Object & getTheObj(); //the Obj won't get changed when calling this
//function
};

【在 l*********u 的大作中提到】
: 同意。
: return constant的function,应该是某个"蛋疼帝"想出来滴 :)

1 (共1页)
进入JobHunting版参与讨论
相关主题
这小段code有什么问题吗?大牛来做一下这道题
两道面试题,请大家说说看法请教operator const char*() 的问题
问个c++题请问一道c++题目
C++ Q83: 这个const_cast什么意思?C++ Q29: extern and const together
C++: 如何对const data member做assignment?C++ Q48: illegal operation (C33)
有人帮我看看这个C++class的定义为什么是合法的吗?C++ 面试题
请教一个C++问题搞不清C++里的constant expression
请教一个const和non const的C++问题请问如何准备C/C++面试
相关话题的讨论汇总
话题: const话题: c++话题: int话题: function话题: constant