149 Answered Questions for the topic C++

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
C++

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
C++

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
C++

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
C++

10/04/19

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
C++

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

When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used?

What are the proper uses of: - `static_cast` - `dynamic_cast` - `const_cast` - `reinterpret_cast` - C-style cast `(type)value` - Function-style cast `type(value)` How does one decide which... more
C++

09/30/19

What are virtual functions

C++

09/28/19

Is it possible to write a template to check for a function's existence?

Is it possible to write a template that changes behavior depending on if a certain member function is defined on a class? Here's a simple example of what I would want to write: ... more
C++

09/28/19

How to concatenate a std::string and an int?

I thought this would be really simple but it's presenting some difficulties. If I have std::string name = "John"; int age = 21; How do I combine them to get a single string `"John21"`?
1 3 4 5 6

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.