const-correctness
const and no const methods in c++?
I have a program and many of its classes have some operators and methods with the keyword const like the followings:[详细]
2023-01-20 07:21 分类:问答Qt4 C++ Pointer to const QList of pointers
I got stuck with pointer to const QList of pointers to Foo. I pass pointer to myListOfFoo from Bar object to Qux. I use pointer to const to prevent making any changes outside Bar class. The problem is[详细]
2023-01-20 03:11 分类:问答Why is the endptr parameter to strtof and strtod a pointer to a non-const char pointer?
The standard C library functions strtof and strtod have the following signatures: float strtof(const char *str, char **endptr);开发者_StackOverflow中文版[详细]
2023-01-19 11:19 分类:问答can the functors called from algorithms acting on a map accept pair<K, V> instead of value_type?
I tried to write a short function to invert an std::map<K, V> (I know about boost.bimap, this is for self-education), and found, to my surprise, that the code that GCC 4.4 accepted with -pedanti[详细]
2023-01-19 03:25 分类:问答Is there some ninja trick to make a variable constant after its declaration?
I know the answer is 99.99% no, but I figured it was worth a try, you never know. void SomeFunction(int a)[详细]
2023-01-15 21:51 分类:问答Const pointer argument to a method which delegates to removeAll()
Consider a method like this: void Parent::removeChild(Child *child) { children.removeAll(child); } In this case, since child is never modified itself, one could make it a const pointer. But since c[详细]
2023-01-14 20:42 分类:问答How do you initialise an array of const values in D2?
Essentially, I want to be able to do something like this: struct Foo { const(int)[2] ints; this(int x, int y)[详细]
2023-01-13 23:29 分类:问答Const method that modifies *this without const_cast
The following pattern has arisen in a program I\'m writing.I hope it\'s not too contrived, but it manages to mutate a Foo object in the const method Foo::Questionable() const, without use of any const[详细]
2023-01-11 19:40 分类:问答Can const-correctness improve performance?
I have read numerous times that enforcing const-correctness in your C or C++ code is not only a good practice with regards开发者_StackOverflow中文版 to maintainability, but also it may allow your comp[详细]
2023-01-10 21:48 分类:问答C++ : automatic const?
When I compile this code: class DecoratedString { private: std::string m_String; public: // ... constructs, destructors, etc[详细]
2023-01-06 13:01 分类:问答
加载中,请稍侯......