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

learn more… | top users | synonyms

1
vote
4answers
255 views

Application qos involving priority and bandwidth

Our manager wants us to do applicaiton qos which is quite different from the well-known system qos. We have many services of three types, they have priorites, the manager wants to suspend low priority ...
2
votes
2answers
276 views

Robustness and pointer safety in C++

I'm currently building a server responsible of storing and managing few million records of fairly complex and interconnected data. For reasons beyond my control the work has to be done with C++. I ...
1
vote
2answers
202 views

What is the purpose of creating a member function with the same type as its class?

I'm sure I'll botch some of the specific terminology, but what is the difference between object and object2 in this implementation? Is the only purpose of the first method (prototyping the class's ...
-2
votes
1answer
111 views

What GUI is used in industry for c++ [on hold]

What's the standard GUI designer used in industry for C++? From reading this question, I assume QT? I want to know, if I walked into a C++ software house tomorrow, what would I expect them to be ...
1
vote
2answers
77 views

What is the name of a type that is defined from a template?

To give a complete example, let's say I have a template class that I now use to generate a type definition: template <typename T> struct A {}; using X = // I'm not asking about this ...
-3
votes
0answers
25 views

Execution of char *(*ptr)[]= &arrayOfStrings; [on hold]

Recently I came across this code block char *arrayOfStrings[]={"Monday","Tuesday","Wednesday","Thursday","Friday"}; char *(*ptr)[]= &arrayOfStrings; // LINE A Basically the code was to ...
1
vote
1answer
74 views

Is there a good name for this pointer template?

I'm looking for a proper name of a class template with the following features: It's interface would look something like this, where Foo is a placeholder for the name I'm looking for. ...
11
votes
4answers
1k views

Why do all <algorithm> functions take only ranges, not containers?

There are many useful functions in <algorithm>, but all of them operate on "sequences" - pairs of iterators. E.g., if I have a container and like to run std::accumulate on it, I need to write: ...
-3
votes
0answers
38 views

Reading texts messages into computer for use [on hold]

I was referred here after asking this question on Stack Overflow: I want to do a project where I would write a program that takes a file that has read all of my texts messages and then counts the ...
-4
votes
0answers
61 views

Why do i get different results when i enter same input? [closed]

This is a program where i make a linked list and print out the values of the linked list. When i enter a specific sequence of numbers, sometimes the program terminates out of nowhere, and sometimes it ...
-3
votes
0answers
58 views

Calling a function in an operator overload? [migrated]

I have a class A, class A{ private: int num; public: A(int n){ num = n; }; int getNum(){ return num; } A operator+(const A &other){ int newNum = num + ...
0
votes
1answer
302 views

Interface questions for using Command Pattern and Dependency Injection together

I have many projects that have essentially the same high level requirement: test all hardware on a device. Each device can have a different communication protocol, requires different test equipment to ...
3
votes
1answer
218 views

Is checking for cin.eof() really necessary?

I have written a simple program that reads character input from the keyboard within a For loop. My professor has taken away 10 points for not checking the input using cin.eof. I don't understand why ...
-2
votes
0answers
37 views

How to transfer data back and forth between a client and a server on a network [closed]

I have the mandate of transferring data (~3-10mb) back and forth between a client and a server. I ideally need this to work in Windows and Linux. (I would like to stick to c# but can easily ...
0
votes
0answers
3 views

What is the reason behind this Eclipse behavior due to changing an Environment Variable? [migrated]

I have two versions of Eclipse that I use (Indigo for C++ and Helios for Java). I've used both for years without problems. Last week I needed to view Java Bytecode, so in my Environment Variables I ...
-1
votes
2answers
111 views

Does GCC optimize code to remove useless variable read operations? [closed]

I'm using GCC on ununtu 14.04. My program is written in c++ and in a case i need to check the amount of time the program needs to read a large integer array. what is the best way to do this without ...
-3
votes
1answer
64 views

dll of c++ project to be used in c#-project [closed]

I would like to create a dll so that I could use an engine written in c++ for a c#-project. I have tried to google for answers without any perfect results. Just a hint on what to search for would be ...
3
votes
3answers
2k views

How to setup the c++ rule of three in a virtual base class

I am trying to create a pure virtual base class (or simulated pure virtual) my goal: User can't create instances of BaseClass. Derived classes have to implement default constructor, copy ...
-2
votes
0answers
23 views

Creating a .avi file using SDL [closed]

I would like to store a movie file created manually through a program in C++ using SDL as a graphic library. I know how to store individual frames, but I don't know how to store it directly as a movie ...
0
votes
0answers
17 views

Code Coverage Reporting with Visual Studio 2013 Professional for native C++ [migrated]

Using the C++ unit testing framework with Visual Studio 2013 Professional, one can write unit tests and run them from within the IDE, but in order to generate any coverage reports, apparently, one ...
0
votes
2answers
88 views

C++ Type of a functor returned by bind

I'm currently programming a chess program in C++. The algorithm for searching is alphaBeta, that's why I sort the moves before going through them and evaluating them. My main class is the class ...
0
votes
0answers
13 views

C++ Matrix multiplication speed custom iterator [migrated]

I am currently writing a linalg library, for educational purposes and personal use. As part of it I implemented a custom matrix class with custom row and column iterators. While providing very nice ...
2
votes
3answers
156 views

Disallow non-local storage of an object

I need to write a class in C++ that acquires a hardware resource and releases it again when it is destroyed. Basically that can be done in the constructor and destructor of the class. The difficulty ...
25
votes
4answers
17k views

Why is #include <iostream.h> bad?

I was reading another thread where a guy asked about C++ books for beginners, and one of the programmers answering wrote this: Some warnings: avoid all books that present an "hello world" stating ...
2
votes
1answer
144 views

What are the main differences between C++ templates and Java generics? [closed]

I'm a beginning C++ programmer coming from Java. It feels to me that C++ templates and Java generics are actually pretty similar. You use them in pretty much the same occasions and in the same way. ...
1
vote
3answers
189 views

How to abide the “allocate in caller” rule when the size is computed in the callee?

Let's say we have an opaque type handle_t that is managed through a simple interface with functions such as: handle_t *handle_init(void); int handle_do(handle_t *); void handle_free(handle_t *); ...
2
votes
1answer
266 views

Are there advantages to declaring stack variables constant in C++

It's not clear to me what benefits there are of declaring your stack variables as constant in C++, I was hoping somebody might explain the benefits and purpose for this technique. For example: void ...
0
votes
1answer
163 views

Does C++ abuse the stack? [closed]

Somewhere on the internet, I remember reading someone complain about how C++ puts so much more stress on the stack than C. They didn't go any further to explain what they said, but I understand that's ...
1
vote
1answer
44 views

saving connectivity information in a nodes/edges network

I want to implement the A* algorithm. I have a network with Nodes and Edges, both are classes. Now, I am unsure how to approach the connectivity information. Should a node know which edges depart ...
0
votes
0answers
165 views

Move semantics in C++ - Move-return of local variables

My understanding is that in C++11, when you return a local variable from a function by value, the compiler is allowed to treat that variable as an r-value reference and 'move' it out of the function ...
42
votes
16answers
7k views

Languages on a resume: Is it better to put “C/C++” or “C, C++”?

I'm graduating in a couple of weeks, and my resume (as expected) lists the languages that I've had experience with. Previously I've put "C/C++", however back then I didn't have that much experience ...
5
votes
3answers
3k views

Is objective-C++ being phased out? [closed]

Is apple phasing out support for objective-c++? Note the following: In the Objective-C language manual, there used to be a section on mixing objective-c and c++. That section is now missing. Links ...
1
vote
2answers
243 views

C++ returning references

Looking at making a GUI library for a game engine. I generally avoid pointers if I don't need them and in my below example I find that I don't and it works, but just curious if this design is ...
-1
votes
1answer
62 views

Creating a generic framework for application loading [closed]

I have multiple applications that use a generic framework for creating a graphical user interface. All run with a certain gui.cpp (600 lines) and gui.h (150 lines) containing the int main() function, ...
2
votes
3answers
276 views

What should I do in C++ when implementing a container class: storing objects by value or by reference?

I'm new to C++, coming from Java. In Java, all variables (except for primitives) are essentially pointers. They hold the address of whatever they're 'holding'. So any Java data structure stores it's ...
6
votes
5answers
3k views

Alternate string formatting options in C++?

I'm looking at optimizing some string formatting code that's hit a lot in our code. We had been using ostringstream, and I converted the code to use sprintf (actually Microsoft's more secure ...
4
votes
1answer
77 views

Handling interface segregation in C++

I'm designing a "view" handling system for a game. The goal is to be able to have different "views" that can be shown in sequence or stacked on-top of each other. For example, the initial splash ...
2
votes
4answers
294 views

Is this a commonly encountered situation in C++? Is there a pattern to handle it?

I am writing a game in C++, and something I have noticed is that I have many resource files which need to be loaded after a particular point in initialization. For example, OpenGL textures and VAOs ...
3
votes
6answers
338 views

Unit test private method in c++ using a friend class

I know that this is a debated practice, but let's suppose that this is the best option for me. I am wondering about what is the actual technique to do this. The approach that I see is this: 1) Make a ...
0
votes
2answers
92 views

What do you call the line/s of code that declare that a class or function is a template? [closed]

I'm writing some macros which declare template types and I'm a bit stumped for terminology. To illustrate, take the following example: // template class declaration template <typename A, typename ...
1
vote
1answer
155 views

What kind of game mechanics makes sense to be handled on client side? [closed]

I am aware of that is a difficult question and depends on the game mechanics and game type being applied. So, many answers can be given. For the sake of simplicity, it would be better to consider a ...
1
vote
3answers
233 views

How to manage focus for a small set of simple widgets

I'm developing a set of simple widgets for a small (128x128) display. For example I'd like to have a main screen with an overlay menu which I can use to toggle visibilty of main screen elements. Each ...
-1
votes
2answers
295 views

FizzBuzz on Large Scale

So I was asked to create FizzBuzz at an interview... Easy enough but then they say what if there is a million data points. ie. divisible by 3 divisble by 5 divisble by 6 up until a billion. What is ...
-2
votes
2answers
71 views

Debug symbols change application execution [closed]

I have to set up remote debugging for a multi threaded application running on a embedded device. C++ is the language. I've gotten so far and got the remote debugging working for a simple application, ...
31
votes
6answers
13k views

Why does Facebook convert PHP code to C++? [closed]

I read that Facebook started out in PHP, and then to gain speed, they now compile PHP as C++ code. If that's the case why don't they: Just program in c++? Surely there must be SOME errors/bugs when ...
13
votes
3answers
991 views

How would you unit-test or perform the most effective automated testing on graphics code for OpenGL?

I'm writing a game and the accompanying graphics engine on top of OpenGL in C++. Im also a fan of good coding processes and automated testing. Graphics code + testing seems pretty immiscible, since ...
0
votes
3answers
278 views

C++ Chess board design and smart pointers [closed]

I wrote a Chess engine in Java and I am porting it over to C++. I am new to C++. The idea: I have a Board object which holds a 2-dimensionnal array of Piece objects. Queen, Rook, Bishop, etc are ...
-3
votes
0answers
26 views

c++ Need help with arithmetic operations [migrated]

I need to make a program that basically reads the 2 numbers that the user inputs and then displays each number by adding, diving, subtracting, and multiplying it all at the same time. This is what i ...
6
votes
4answers
520 views

Does internal state “leak” when it influences externally-visible behavior?

I have a method (in C++) which generates a value based on a parameter and the parameters from previous calls. Calling it more than once with the same parameter may generate different values each time. ...
3
votes
2answers
136 views

Decision making and maintenance

I'm trying to find an elegant way to implement a decision making algorithm that allow easy maintenance because the conditions for the decision making might change often. I'm going to try and be more ...