大约有 4,600 项符合查询结果(耗时:0.0228秒) [XML]
Why is there no std::stou?
C++11 added some new string conversion functions:
3 Answers
3
...
What is a smart pointer and when should I use one?
...at the time, which was smart pointers provided by the Boost library. Since C++11, the standard library has provided sufficient smart pointers types, and so you should favour the use of std::unique_ptr, std::shared_ptr and std::weak_ptr.
There was also std::auto_ptr. It was very much like a scoped ...
Is there a performance difference between i++ and ++i in C++?
...ive Summary: Use ++i if you don't have a specific reason to use i++.]
For C++, the answer is a bit more complicated.
If i is a simple type (not an instance of a C++ class), then the answer given for C ("No there is no performance difference") holds, since the compiler is generating the code.
Howe...
Iterator Loop vs index loop [duplicate]
I'm reviewing my knowledge on C++ and I've stumbled upon iterators. One thing I want to know is what makes them so special and I want to know why this:
...
How to sum up elements of a C++ vector?
...
Actually there are quite a few methods.
int sum_of_elems = 0;
C++03
Classic for loop:
for(std::vector<int>::iterator it = vector.begin(); it != vector.end(); ++it)
sum_of_elems += *it;
Using a standard algorithm:
#include <numeric>
sum_of_elems = std::accumulat...
What are the rules for calling the superclass constructor?
What are the C++ rules for calling the superclass constructor from a subclass one?
10 Answers
...
Elegant solution to duplicate, const and non-const, getters? [duplicate]
...
I recall from one of the Effective C++ books that the way to do it is to implement the non-const version by casting away the const from the other function.
It's not particularly pretty, but it is safe. Since the member function calling it is non-const, the ob...
Visual Studio 2010 - C++ project - remove *.sdf file
...d in the same folder)
Go to Tools -> Options -> Text Editor -> C/C++ -> Advanced
In the "Fallback Location", set "Always Use Fallback Location" to True and "Do Not Warn If Fallback Location Used" to True.
In "Fallback Location" you can either put a path like C:\Temp or if you leave i...
How to navigate through a vector using iterators? (C++)
...e following is an example of a typical access pattern (earlier versions of C++):
int sum = 0;
using Iter = std::vector<int>::const_iterator;
for (Iter it = vec.begin(); it!=vec.end(); ++it) {
sum += *it;
}
The advantage of using iterator is that you can apply the same pattern with other...
Why do we need virtual functions in C++?
I'm learning C++ and I'm just getting into virtual functions.
26 Answers
26
...