【发布时间】:2013-02-25 23:40:22
【问题描述】:
以下哪一个更正确,使用更广泛?实际问题是最后一个问题,我认为行为发生了变化。
int *test; //for this, it is probably both?
int* test;
int& test;
int &test;
实际问题:
const int test;
int const test;
const int* test;
int* const test; //<-- I guess this also have a different meaning if I consider the last one?
const int& test;
int const& test; //also, considering last one, any difference?
const int*& test;
int* const& test; //<-- this is the correct one for stating "I won't modify the passed object, but I may modify the one pointed"? I have had problems with the other one sometimes, does the other one has some other meaning?
const int* const& test; //<-- another meaning?
如果你知道这个主题中的任何视觉“歧义”,我会很高兴。
【问题讨论】:
-
如果您愿意阅读,里面是一个有效的问题。如果您不知道答案,请停止提议关闭。或者如果你不在乎,做不在乎。
-
@JesseGood 是的,我一直在阅读。没有与强硬的参考组合。我认为这一切都是由指针引起的。不过我会等待答案。
-
引用问题与指针问题相同,请记住 C++ 非常重视类型,即
int& i。