c++-faq

How do I pass an array to a function?

You need the array to be an input parameter. void f (int &heap[]) { } The compiler swears at the code above.

What is the difference between references and pointers in C++

What is the fundamental difference between a reference and a pointer in C++? When is it better to use a reference, and when is a pointer? What are the limitations of the former, and what are the latter?

Modules in C++ - what is it and when to use it?

What are modules? Why are they needed and how do they differ from header files? When should I use one, and when should I use the other?

Why do I need to write typename to specify the type?

When using templates, sometimes you need to write typename for types - when and why do this? template <class T> inline ... l.begin(); pos!=coll.end(); ++pos) { std::cout << *pos << ' '; } std::cout << std::endl; }

Take out a template class method в.срр

How do I move a template class method from a header to a cpp ?

Has anyone met sizeof (char)!= 1 in their practice?

Interested in one of the answers to a recent question on C++ (C) Calculating the length of a string without using strlen() ... we are talking about C (C++), not Java, etc. At the same time, has anyone ever dealt with a byte not consisting of 8 bits ?

are static cast and (int) the same thing?

I can't understand why static_cast, if all the same can be done by directly specifying the type.

Keyword ' auto`

What does the keyword auto mean in c++ and where does it apply?

How do I write my own allocator?

It is often written that with a non-standard allocator, the code can work faster, but how do I write my own allocator?

Reference to an unresolved external character (possible reasons)

When you try to build a program, you receive an error message of one of the following types: reference to an unresolved ... ence ... unresolved external symbol ... undefined reference to ... What does this mean, and how do I fix this error?

Dynamic Link Libraries (DLLs)

How to dynamically connect a DLL in C++?

Books and learning resources on C++

In this question, the literature on the C++language is collected Format: First Name Last Name - "The title of the book i ... (when it will be) This list is included in the community-supported Collection of educational resources on programming.

Namespace (using namespace std;)

Very often on the Internet I see how many programmers diligently write programs everywhere using std:: in the code. Why are t ... nd the code starts to "breathe". Or is this a bad tone and it is worth retraining to use std:: directly in the program code?

Where can I get the C++standard?

Many of the answers refer to the C++ standard, and where to get it? This question is part of the community-supported Collection of educational resources on programming.

Russian in the console

I teach C++ from Stroustrup's book, Russian characters are not output. Here is the code: #include <iostream> #include ... tlocale tried different (0, ""), "", "Rus", etc. In Code:: Blocks, everything works without quacks. Even without setlocale.

Why is it considered wrong to write while (!input stream.eof())?

Various sources say that using std::istream::eof() is a sign of bad code and that in particular it is wrong to write: while ... stream.eof()) { input_stream >> value; process(value); } What's wrong with this code? How to write correctly?

How does an empty default constructor differ from =default;?

For the default constructor, how does an empty body differ from what is obtained with =default? X::X() {} // и X::X() = default;

When to write std:: endl and when '\n'?

There are two ways to write a line feed - std::endl and \n. What's the difference? When to use what?

When dividing numbers, the fractional part disappears

I divide two numbers by each other, for example 1 / 2 and expect to get 0.5 as a result, since I assign the result to a float ... ream> int main() { double d = 1 / 2; std::cout << d << "\n"; } 0 What could be the problem?

What is internal and external linking?

What is internal and external binding in C++?