const-correctness
Do I still write String^ const in C++/CLI
In C++ it\'s recommended to have const-correctness everywhere. But s开发者_JAVA技巧ince in .Net world, the string content cannot be changed, (new string will be created), do I still write String^ cons[详细]
2022-12-25 21:07 分类:问答Modifying a const through a non-const pointer
I\'m a bit confused what happened in the following code: 开发者_开发技巧 const int e = 2; int* w = ( int* ) &e;// (1) cast to remove const-ness[详细]
2022-12-24 17:34 分类:问答How to return a 'read-only' copy of a vector
I have a class which has a private attribute vector rectVec; class A { private: vector<Rect> rectVec;[详细]
2022-12-23 12:32 分类:问答Why am I getting an error converting a ‘float**’ to ‘const float**’?
I have a function that receives float** as an argument, and I开发者_开发技巧 tried to change it to take const float**.[详细]
2022-12-23 10:03 分类:问答When should a member function have a const qualifier and when shouldn't it?
About six years ago, a software engineer named Harri Porten wrote this article, asking the question, \"When should a member function have a const qualifier and when shouldn\'t it?\" I found it to be t[详细]
2022-12-23 09:39 分类:问答Does it ever make sense to make a fundamental (non-pointer) parameter const?
I recently had an exchange with another C++ developer about the following use of const: void Foo(const int bar);[详细]
2022-12-22 20:59 分类:问答Using traits in C++
This question is related to my last one. I am trying to solve the problem usingtraits<T>and traits<T*>. Please consider the following code.[详细]
2022-12-21 05:57 分类:问答Is it a good practice to free memory via a pointer-to-const
There are many questions discussing the details of C and C++ dealing with pointer-to-const deletion, namely that free() does not accept them and that delete and delete[] do and that constness doesn\'t[详细]
2022-12-21 00:34 分类:问答const correctness and return values - C++
Please consider the following code. struct foo { }; template<typename T> class test { public: test() {}[详细]
2022-12-20 15:30 分类:问答Why isn't it legal to convert "pointer to pointer to non-const" to a "pointer to pointer to const"
It is legal to convert a pointer-to-non-const to a pointer-to-const. Then why isn\'t it legal to convert a pointer to pointer to non-con开发者_如何学Pythonst to a pointer to pointer to const?[详细]
2022-12-20 00:16 分类:问答
加载中,请稍侯......