Tagged Questions

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

learn more… | top users | synonyms

-2
votes
0answers
19 views

Difference in keywords and operators in C and C++ [on hold]

I have been programming in C for 3 years as part of my engineering degree, and I'd now like to learn C++. I think it will really help if I could be told what new keywords and operators are added in ...
1
vote
0answers
37 views

Qt: internationalization of images [migrated]

I am aware of utilities like GNU gettext for making the software multilingual. You give it a string id and it will return the translated string. But I also need this for images in Qt. For example, if ...
2
votes
2answers
106 views

Will there be a memory or processing time difference between a class member function and a global function

I'm writing a neuron network simulation program and every operation or additional byte per neuron scales insanely. I prefer C++ as a language over the others, but now I'm wondering if the class ...
0
votes
1answer
57 views

Extending a class for debugging: public API, hidden implementation or something else?

I'm working on a fairly large project that involves 3D drawing, and I want to add some visualizers (for example, to see the bounding boxes of the objects) to make debugging easier. However, I'm having ...
-5
votes
0answers
45 views

To built the GUI of battleship [on hold]

Currently I am working on a battleship game for multiple clients. The code is in JAVA which is back-end. now I want to make GUI of game i.e. front-end. I am confused which language will be good for ...
-4
votes
0answers
29 views

Rapid desktop screen capture on Windows OS [on hold]

I want to capture the desktop screen image on Windows. I know about the CreateCompatibleDC and CreateCompatibleBitmap... functions in C++ but it they are very slow. I need a more rapid method that ...
-3
votes
0answers
22 views

Finding Index and loading data of file in big list? [on hold]

I am making a little big program. I want to mix thousands of files into one file But searching index of file and loading data are very slow. Is there any way to find index of files in list of many ...
-2
votes
2answers
133 views

Why doesn't array declaration guarantee proper memory allocation whereas malloc does? [on hold]

In C++, when I declare an array like int array[10];, it sometimes uses memory assigned to other variable where as this problem is non-existent when I use an integer pointer and malloc to allocate ...
-2
votes
0answers
21 views

Getting started with building georeferencing software for UAV Images [on hold]

How can I get started with building georeferencing software for UAV Images. I have heard that OpenCV C++ Library is the best option. How can i start writing actual codes. What kind of things need to ...
-3
votes
0answers
34 views

C++ Accessing a variable in a tree stored in vector of type struct [on hold]

I am looking at this code online and am not sure how to access a particular variable stored inside the tree. For example, the offset.x is being pushed into the vector children, so how would I access ...
3
votes
6answers
221 views

Explicitly define enum values, even if the default value is the same?

There are times when an enum's values are important: it is not necessary for them to be unique, they also need to have specific values. In such cases, should the values be explicitly defined, even if ...
0
votes
0answers
135 views

Why doesn't grep return TRUE in C++? [migrated]

I'm adapting some of my code from Bash to C++ and I have no idea why this allways returns FALSE. #include <iostream> #include <stdlib.h> int main() { if ( system ("grep -q ...
5
votes
2answers
481 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
259 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
138 views

What GUI is used in industry for c++ [closed]

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
84 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 ...
1
vote
1answer
83 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. ...
-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
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
116 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
222 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 ...
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
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 ...
0
votes
2answers
90 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 ...
2
votes
3answers
159 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 ...
2
votes
1answer
150 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. ...
0
votes
1answer
168 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
45 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
173 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 ...
2
votes
3answers
286 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 ...
4
votes
1answer
81 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
300 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 ...
0
votes
2answers
93 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
votes
2answers
308 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, ...
1
vote
1answer
160 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 ...
3
votes
6answers
359 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
3answers
286 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
524 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
174 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 ...
1
vote
2answers
199 views

Organise C++ classes around SQL database

My question is about how best to organize C++ classes around a database model, and I understand this may appear very elementary. The software I propose to create will do the following. It is intended ...
1
vote
3answers
336 views

C++: Metaprogramming with a compiler API rather than with C++ features

This started out as a SO question but I realized that it is quite unconventional and based on the actual description on the websites, it might be better suited to programmers.se since the question has ...
0
votes
3answers
279 views

Good 'real life' example of operator overloading C++ [closed]

What are examples of classes to use operator overloading on in C++? All the examples and tutorials I can find on the net use non-sensical classes/objects (foo/bar, one or two integers..) What are the ...
0
votes
2answers
133 views

How to organise and label methods, intended for debug?

I have a class System, which uses a bunch of other classes, to achieve a complex signal processing. In debugging System, one needs to observe the output signal for patterns. This is not achievable by ...
1
vote
4answers
398 views

How to work around Java's lack of pointers to pointers when working with linked data structures? [closed]

I've learned from a textbook how to implement binary search trees recursively in Java, and am working on implementing them nonrecursively. I've found a simple and elegant way to implement an insert ...
2
votes
1answer
160 views

How do multiple levels of inheritance affect virtual function call overhead in C++?

I am considering using a class hierarchy with more than a single level of inheritance, where virtual member functions form a "chain", for example: struct Base { virtual void foo(); }; struct D1 : ...
3
votes
4answers
174 views

Storing a pointer to an argument passed by (non-const) reference

When designing an interface for passing objects which are meant to be stored for later use and which should not be 'null', I am always a bit uncertain if the argument should be passed by reference or ...
0
votes
2answers
130 views

Can I create a type, typedef or using statement that results in a different type if instantiated a second time or more?

Suppose I have a class that evaluates some computationally intensive function: class Value { private: int eval() { mCached = ExpensiveOperation(); return mCached; } static int ...
0
votes
0answers
44 views

API for accessing CTS and DSR signals of serial port

I'm trying to improve another abstraction of the serial port. The project involved often needs to check one of the single control signals CTS and DSR. This is currently done by a call to ...