598 Answered Questions for the topic C++

C++

06/02/19

How would I get access of a variable in a namespace in c++?

For example: namespace space1{ int var; namespace space2{ int var; namespace space3{ int var; } } How would I access the variable from space1... more
C++

05/31/19

What's the purpose of using braces (i.e. {}) for a single-line if or loop?

I'm reading some lecture notes of my C++ lecturer and he wrote the following: > 1. Use Indentation // OK > 2. Never rely on operator precedence - Always use parentheses // OK > 3.... more
C++

05/31/19

How do you get assembler output from C/C++ source in gcc?

How does one do this? If I want to analyze how something is getting compiled, how would I get the emitted assembly code?
C++

05/30/19

C++ code file extension? .cc vs .cpp?

I have seen C++ code saved as both `.cc` and `.cpp` files. Is there a difference between the two? I am mainly concerned with programs on Linux systems.

05/29/19

Is there a Java equivalent or methodology for the typedef keyword in C++?

Coming from a C and C++ background, I found judicious use of **`typedef`** to be incredibly helpful. Do you know of a way to achieve similar functionality in Java, whether that be a Java... more
C++ Java C D

05/29/19

Is D a credible alternative to Java and C++?

Is the [D language](http://www.digitalmars.com/d/) a credible alternative to Java and C++? What will it take to become a credible alternative? Should I bother learning it? Does it deserve... more

Why are C++ inline functions in the header?

<sub>NB This is not a question about how to use inline functions or how they work, more why they are done the way they are.</sub>The declaration of a class member function does not need... more

What is a scalar Object in C++?

C++ Linux G++

05/24/19

usr/bin/ld: cannot find -l<nameOfTheLibrary>?

I'm trying to compile my program and it returns this error : usr/bin/ld: cannot find -l<nameOfTheLibrary> in my makefile I use the command `g++` and link to my library which is a symbolic... more

The consequences and pros/cons of flushing the stream in c++?

I have recently read an article which stated that using `\ ` is preferable to using `std::endl` because `endl` also flushes the stream. But when I looked for a bit more information on the topic I... more
C++

05/24/19

Convert char to int in C and C++?

How do I convert a `char` to an `int` in C and C++?
C++

05/24/19

What is an unsigned char?

In C/C++, what an `unsigned char` is used for? How is it different from a regular `char`?
C++

05/23/19

Printing 1 to 1000 without loop or conditionals?

**Task**: Print numbers from 1 to 1000 without using any loop or conditional statements. Don't just write the `printf()` or `cout` statement 1000 times.How would you do that using C or C++?
C++

05/22/19

Static linking vs dynamic linking?

Are there any compelling performance reasons to choose static linking over dynamic linking or vice versa in certain situations? I've heard or read the following, but I don't know enough on the... more
C++

05/21/19

Is there a technical reason to use > (<) instead of != when incrementing by 1 in a 'for' loop?

I almost never see a `for` loop like this: for (int i = 0; 5 != i; ++i) {}Is there a technical reason to use `>` or `<` instead of `!=` when incrementing by 1 in a `for` loop? Or this... more
C++

05/16/19

How do you reverse a string in place in C or C++?

How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?
C++

05/15/19

How do I list the symbols in a .so file?

How do I list the symbols being exported from a .so file? If possible, I'd also like to know their source (e.g. if they are pulled in from a static library).I'm using gcc 4.0.2, if that makes a... more
C++

05/13/19

What are C++ access specifiers ?

C++

05/12/19

Is the sizeof(some pointer) always equal to four?

For example:`sizeof(char*)` returns 4. As does `int*`, `long long*`, everything that I've tried. Are there any exceptions to this?

05/07/19

Most efficient/elegant way to clip a number?

Given a real (n), a maximum value this real can be (upper), and a minimum value this real can be (lower), how can we most efficiently clip n, such that it remains between lower and upper? Of... more
C++

05/06/19

Is it possible to have a recursive inline function in C++?

C++

05/06/19

What are the important topics in C++?

C++

05/06/19

Which is better option to use for dividing an integer number by 2?

Which of the following techniques is the best option for dividing an integer by 2 and why?Technique 1: x = x >> 1;Technique 2: x = x / 2;Here `x` is an integer.
C++ C Unix Macos

05/06/19

What are the differences between .so and .dylib on osx?

.dylib is the dynamic library extension on OSX, but it's never been clear to me when I can't / shouldn't use a traditional unix .so shared object.Some of the questions I have: - At a conceptual... more

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.