Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 123788

Questions about C++, a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.

1 vote

Processor architectures for testing C/C++ portability

At this point in time, from the point of view of high level languages there is very little difference between the most common processors. At the moment, I write code for 64 bit x86 and ARM processors. …
gnasher729's user avatar
  • 47.5k
0 votes
Accepted

Help with optimizing virtual method

I bet it doesn’t make a difference. If it does: Implement your function with a non virtual inline function named inline_f which has a T* pthis as the first argument and put it in the header file. Then …
gnasher729's user avatar
  • 47.5k
2 votes

What are the best practices when implementing C++ error handling?

It's rather bizarre how people descend into the technicalities of an implementation. The most important question is how to correct appropriately to an error, and how to keep the damage minimal. Step 1 …
gnasher729's user avatar
  • 47.5k
-3 votes

Implementing factory that return the correct type

You have three weaknesses. Your classes should not be aware that they can be created by a factory. Adding them to the factory should cause no change in the class. Instead, you decided they all need a …
gnasher729's user avatar
  • 47.5k
1 vote

In C++, why does the main function use 'char *argv[]'?

The operating system has code that sets up these parameters and calls main() with these parameters. The version for C is easy to implement: The arguments are stored and we get one char* for each, then …
gnasher729's user avatar
  • 47.5k
2 votes

Immutability across programming languages

I'd start with C and C++, where things are reasonably simple. You have "objects" in memory, not in the sense of object oriented programming, but items that can be read or changed. These "objects" can …
gnasher729's user avatar
  • 47.5k
0 votes

C/C++: Which conversion warnings make sense in practice?

You get the int-to-float warning because int > 2^24 are usually converted with an error. My rule is that you should use double unless you can give a good reason to use float. So what is your reason to …
gnasher729's user avatar
  • 47.5k
1 vote

Are there real world examples demonstrating reasonable performance improvement by using move...

There are objects that can exist only once. For example, an open file with exclusive read/write access to a file on your hard drive. You can’t have two of these objects, even for the shortest amount o …
gnasher729's user avatar
  • 47.5k
5 votes

Is the inability to find code by searching for a class name a reason to avoid using auto in ...

It depends on how clever your development software is. Searching for all uses of MyClass as text is easy. But some IDEs have the ability to search for MyClass as a symbol as well. That could be by usi …
gnasher729's user avatar
  • 47.5k
3 votes
Accepted

Why do you need to use pass by reference in C++ to change the value of the arguments inside ...

Let’s say you have a variable int x in your function. You call a function with a parameter int i, like f(x); You passed a value. Inside the function f the parameter is turned into a variable, as if y …
gnasher729's user avatar
  • 47.5k
1 vote

C++ and memory safety

Before you go in deep, look at what “memory safe” in other languages means. A[i] = 0 with out of range i can overwrite a random memory location. Or it can instantly crash your software. Or it can thro …
gnasher729's user avatar
  • 47.5k
0 votes

Is it good practice to rely on headers being included transitively?

My rule: Every header should compile on its own, so if a.h needs b.h then it includes it. Every header has protection against multiple inclusion. And source files include only what they need. In addit …
gnasher729's user avatar
  • 47.5k
-1 votes

Is updating a macro value in the Xcode preprocessor's macros violating the open–closed princ...

The open-closed principle is there to help you. So if you have the choice between violating the open-closed principle and not getting your job done, you get the job done. But you also have a fundament …
gnasher729's user avatar
  • 47.5k
-3 votes

Use case comparison for std::optional vs default argument

“optional” should be used for things that are genuinely not there, and not for default values. So if it is possible that there are no print settings, make it optional. If you decided to use default va …
gnasher729's user avatar
  • 47.5k
2 votes

Why use a special "Name" class (instead of just a string) for representing object names in C++?

If you have a “Name” class instead of string, you can use it to split into family name and given name, salutation, ordering (that’s why I didn’t say “first name” because for some people the family nam …
gnasher729's user avatar
  • 47.5k

1
2 3 4 5
11
15 30 50 per page