598 Answered Questions for the topic C++

C++

02/24/20

create a very particular calculator that works with 3 integer numbers at a time rather than the usual 2 in regular calculators.

1. So, first, ask the user to enter the desired operation (use cin) and store the value in a variable named operation. The user input will consist of a single letter or symbol. Entering: a)... more

Why the last value appear in hexadecimal rather than decimal? c++

struct Node{ Node* next; int num;};int main(){ Node* ptr = new Node; ptr->num = 11; ptr->next = NULL; cout << ptr << " "; cout << &ptr->next << " "; cout... more
C++

12/04/19

Write a program that allocates an array large enough to hold a ... (continues in description)

(continued from title) ...user-defined number of test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should... more

12/02/19

Modify your inventory management system created in below to use vectors and iterators.

//*This program to assist a user to input the inventory information management//into a file that has created from the program itself only once and the data will be saved automatically#include... more
C++

11/30/19

What code i use?? C++

Imagine you own company and you want to develop an electronic system for your customers to browse inventory and purchase items you have in stock. Your inventory is kept in a text file and may... more

10/26/19

How to design a function that will let only the minimum elements be at the bottom? C++

Write the body of the user function below that changes a stack so that all occurrences of the smallest item are at the bottom of the stack, while the order of the other items remains the same. For... more

10/16/19

Im not sure how to do this but it would be nice to get some help. C++ language

WRITE AN INTERACTIVE PROGRAMthat allows the user to enter (at least two)....UP-TO 15 vectors that are to be added........display the resultant on the screen
C++

10/11/19

What is C++11 Move Semantics?

C++

10/10/19

Why should C++ programmers minimize use of operator new?

Why do C++ programmers recommend minimizing the use of operator new? Isn't operator new the C++ way of allocating dynamic memory for C++ objects on the heap; in which case, why minimize its usage?... more
C++

10/07/19

push_back vs emplace_back?

I'm a bit confused regarding the difference between `push_back` and `emplace_back`. void emplace_back(Type&& _Val); void push_back(const Type& _Val); void... more
C++

10/06/19

std::string formatting like sprintf?

I have to format [`std::string`](http://en.cppreference.com/w/cpp/string/basic_string) with [`sprintf`](http://en.cppreference.com/w/cpp/io/c/fprintf) and send it into file stream. How can I do this?
C++

10/06/19

How many levels of pointers can we have?

How many pointers (`*`) are allowed in a single variable? Let's consider the following example. int a = 10; int *p = &a; Similarly we can have int **q = &p; int ***r =... more
C++

10/06/19

How can I iterate over an enum?

I just noticed that you can not use standard math operators on an enum such as ++ or += So what is the best way to iterate through all of the values in a C++ enum?
C++

10/05/19

How to use the PI constant in C++?

I want to use the PI constant and trigonometric functions in some C++ program. I get the trigonometric functions with `include <math.h>`. However, there doesn't seem to be a definition for PI... more
C++

10/05/19

Difference between private, public, and protected inheritance?

What is the difference between `public`, `private`, and `protected` inheritance in C++? All of the questions I've found on SO deal with specific cases.
C++

10/05/19

How do I tokenize a string in C++?

Java has a convenient split method: String str = "The quick brown fox"; String[] results = str.split(" "); Is there an easy way to do this in C++?
C++

10/05/19

What is the difference between 'typedef' and 'using' in C++11?

I know that in C++11 we can now use `using` to write type alias, like `typedef`s: typedef int MyInt; Is, from what I understand, equivalent to: using MyInt = int; And that new syntax... more
C++

10/04/19

How to avoid "if" chains?

Assuming I have this pseudo-code: bool conditionA = executeStepA(); if (conditionA){ bool conditionB = executeStepB(); if (conditionB){ bool conditionC = executeStepC(); if... more

How do I properly fill in and create a While Loop Flowchart and Pseudo code for this? I also need to perform 3 desk checks, details below...

"Farmer Pete’s pigs and sheep are all intermingled. He wants to be able to determine how many pigs and sheep he has by just walking out and counting them one at a time. He also needs to know what... more

10/02/19

Since C++ is an old language why it is still taught in universities and colleges?

Since C++ is an old language why it is still taught in universities and colleges?
C++

09/30/19

Difference of keywords 'typename' and 'class' in templates?

For templates I have seen both declarations: template < typename T > template < class T > What's the difference? And what exactly do those keywords mean in the following example... more
C++

09/30/19

Benefits of inline functions in C++?

What is the advantages/disadvantages of using inline functions in C++? I see that it only increases performance for the code that the compiler outputs, but with today's optimized compilers, fast... more
C++

09/30/19

What is the difference between #include <filename> and #include "filename"?

In the C and C++ programming languages, what is the difference between using angle brackets and using quotes in an `include` statement, as follows? 1. `#include <filename>` 1. `#include... more
C++

09/30/19

Debug vs Release in CMake?

In a GCC compiled project, - How do I run CMake for each target type (debug/release)? - How do I specify debug and release C/C++ flags using CMake? - How do I express that the main executable will... more
C++

09/30/19

What are inline namespaces for?

C++11 allows `inline namespace`s, all members of which are also automatically in the enclosing `namespace`. I cannot think of any useful application of this -- can somebody please give a brief,... 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.