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

learn more… | top users | synonyms

0
votes
0answers
22 views

Difficulty designing my EventHandler class that uses a callback to handle key-presses

I wrote an EventHandler class that takes a std::function<void(char)>, and a std::vector<char> of chars (representing keys). If a key in the vector is pressed, the call-back is executed ...
-2
votes
0answers
25 views

Addition and Subtraction giving incorrect results [migrated]

I made a simple program to add and subtract the given numbers. Let's say the 2 numbers give were 5 and 5. It would print 5 + 5 = 10 and 5 - 5 = 0. Right now I'm not sure what's wrong. I might need a ...
-3
votes
0answers
29 views

What approach to develop a bot player for the Trax game? [on hold]

I have created a fully functional two player game of Trax. It is a Linux console application, written in c++, which saves the current state of the board into a binary file, which in turn can be used ...
-2
votes
0answers
59 views

The correct way to use a for loop in an array C++ [migrated]

I'm having some trouble with a homework assignment dealing with Arrays. I have already read all the text from class (which didn't help me at all), looked up several tutorials on arrays, and searched ...
-2
votes
0answers
16 views

Using getline() with parameters to read through a file and extract specific information? [migrated]

I'm programming a c++ console application for school and I need to read through a .txt file to extract specific informations to use them in classes. For example, here is a portion of the txt file : ...
0
votes
3answers
148 views

Compile-time vs. run-time configuration

I'm starting new project and need to decide on how to handle configuration. I recently run into suckless project. While it has its own issues, I really liked its approach to configuration - just a ...
-3
votes
0answers
15 views

WT C++: How to include bootstrap (its functionalities) in WT code? [on hold]

[Remarks] Like in HTML; it is included in the head tag. How about WT c++? WBootstrapTheme has to be included (what else?)
-1
votes
0answers
28 views

readFromFile reads file from reference in a function help! [closed]

Ok so first this is my first post on stack overflow! Second I need some help on my c++ project! Heres the problem I have a readFromFile function in a class that will accept one parameter (an input ...
-2
votes
0answers
81 views

How much developer efficiency would be lost switching from C# to C++ [closed]

If you switched from C# to C++ how much less developer efficiency would there be? There could be benefits in using c++ for cross platform portability as demonstrated by Herb Sutter ...
5
votes
2answers
191 views

Static console object or dependency injection?

For a current project I have created a Console class which wraps up C++'s usual cout, writes output to a file or uses Console::WriteLine depending on the environment. Currently I've setup my code base ...
1
vote
1answer
113 views

Are there real world examples demonstrating reasonable performance improvement by using move semantics?

(I've asked a similar question on SO but unfortunately it might not be proper, so I also put here; please kindly point out if you think it's a duplicate.) I've heard many words about the move ...
-1
votes
2answers
149 views

Mermaid problem (OOP) [closed]

A Mermaid is half fish and half human. It has upper human body and lower fish body. When under water its upper part swims like a human while its lower part swims like a fish. Please explain how can it ...
1
vote
3answers
318 views

In C++, should I ever declare a local variable in the corresponding header?

So for example, I create a class with two functions: foo.h class foo { public: foo(); void bar(); void ey(); bool m_memberBool; bool localBool; // ??? Should I put this here? }; ...
-1
votes
1answer
45 views

One symbol - one meaning?

It's well known recomendations that: 1) class or function should have one responsibility 2) variable should not be reused in different contexts We can generalize this recomendations to general ...
4
votes
7answers
475 views

Structuring Procedural vs OO code

I have spent the vast majority of my programming career using Java and very OO based C++. I am really interested in learning to think more procedurally, so I have been starting to do some practice ...
1
vote
0answers
75 views

Is the behaviour of floating-point arithmetic defined by the c++ standard?

I started writing this as a SO question but I think it's better suited here. While I'm happy for simply an answer I'm also fond of the "Teach a Man to Fish" phylosophy so I'm happy for people to point ...
2
votes
0answers
63 views

Can't figure out class scheduling issue? [closed]

"You are a college advisor trying to help students plan their academic careers. You have the list of courses in each major and their prerequisites. Students often want to take their major courses as ...
0
votes
1answer
79 views

Receiving information from another application [closed]

I am currently attempting to create an AI which can play games, but learns to play rather than using hard-coded instructions. But, this isn't my problem, my problem is telling the AI whether it has ...
0
votes
0answers
16 views

Calling functions in C++ function is of non-class type [migrated]

I am very new to programming, especially in C++, and am trying to build my first project on my own. A budget program. Criticism is welcome. I'm using a constructor in my main file to call my functions ...
0
votes
1answer
103 views

Moving from C++ to NodeJS - Working with XML and JSON

I need to make a program to compare several large +100MB XML files, find the difference, and spit out JSON. I have written the comparison code in C++ and it performs great but now when I am getting to ...
1
vote
1answer
77 views

Run a c++ program under lots of different data maps

I want to run a c++ program to process a lot of data from different xml files and output results. I run the program once per file and potentially have around 50 different files. The trouble is each ...
2
votes
1answer
88 views

How minor of a case is a class appropriate for?

I'm trying to use composition in an Entity class of mine. So far, an Entity "is" Displayable(inherited an ABC), and "has" a Position(contains a point-like class). I know I will want my Entity to ...
5
votes
2answers
264 views

Transforming XML to JSON in C++

Working with XML in C++ seems a bit of a pain and I'm looking at a way to output JSON. I've stumbled on two different approaches: A) XSLT transformations: ...
4
votes
2answers
163 views

Is there any harm in having classes made up mostly of inherited classes?

Say I have a few base classes: HasPosition supplies a 2D location, and methods to "move". IsDisplayable defines how a class will be displayed in a given graphics library (say, curses), and methods ...
1
vote
5answers
382 views

How to share memory between applications written in C/C++

I'm going through a program written in C/C++ for control in robotics. Basically, three different programs run at the same time, and they communicate via shared memory. Google-ling around I found ...
5
votes
2answers
182 views

Designing exception classes

I'm coding a small library and I'm having some trouble with designing the exception handling. I must say that I am (still) confused by this feature of the C++ language and I tried to read as much as ...
159
votes
9answers
11k views

Why do many exception messages not contain useful details?

It seems there is a certain amount of agreement that exception messages should contain useful details. Why is it that many common exceptions from system components do not contain useful details? A ...
16
votes
8answers
927 views

Is directly using Make considered obsolete?

So I have been coming across many comments/posts/etc regarding creating makefiles directly, and how it is a silly thing to do in 2015. I am aware of tools such as CMake, and I actually use CMake quite ...
2
votes
3answers
265 views

Repetitive code over multiple classes. Best way to centralize code?

I'm working with 3D arrays that I flatten into a 1D arrays with the following index calculation: index = x + WIDTH * (y + DEPTH * z) I'm starting to notice that I'm using the calculation all over ...
0
votes
0answers
55 views

Matching groups of similar lines on a generic matching algorithm

I have to write a program to search through a file containing lines and find lines that match to a degree of tolerance but are not necessarily the same. So for example the following lines would match: ...
2
votes
1answer
209 views

How can C++ make it possible to use dynamic container classes even in embedded systems?

How can C++ make it possible to use dynamic container classes even in embedded systems? Background info: I've been working with PIC (C) and AVR (C++) processors and at the moment (PIC C) I'm ...
3
votes
3answers
340 views

No exceptions C++ and partially constructed objects

Looking over Joint Strike Fighter Air Vehicle C++ Coding Standard, rule AV 73 states something on the lines: Default c++ constructors should be avoided if that means leaving object in a partially ...
-1
votes
0answers
22 views

Programming with Kinect on Ubuntu Linux [migrated]

first time asking a question here so please bear with me if I'm not entirely coherent. I've been attempting to learn how to use the OpenNI, libfreenect, and SensorKinect libraries to create some code ...
0
votes
4answers
201 views

Fixing class Hierarchy design mistakes due to incorrect inheritance

I have a code like this. My derived class man, may not properly have a member function declared pure virtual higher up the hierarchy. eg. WagTail here class mammal{ public: virtual void WagTail() ...
3
votes
2answers
113 views

What kind of base for Decorator: interface, abstract class, non-abstract

What should be at the top of inheritance tree of Decorator design pattern? I mean the base for both components and decorators non-abstract class: has data fields, implements methods abstract class: ...
4
votes
4answers
173 views

Design question concerning proper and practical encapsulation

I have been working on refactoring old code and found a lot of instances of the following type of situation: There is a master object which we call "Application" and there is only one of these. The ...
-3
votes
2answers
135 views

How to visualise this data model?

I have learnt different variants of list data model like Dlist, SList and recursivenodetype-list. But I could not understand/visualise this datamodel as mentioned below in C++ syntax, with an ...
1
vote
1answer
157 views

how can i make a program written in c++ with qt to text and graphic mode?

I have seen in many programs, almost only on linux, that when you run the program with a graphical manager(Clicking the executable) the program runs in a graphical window and when you run it from the ...
2
votes
2answers
73 views

Optional Member Data

I am creating a strong binding of an XML specification and I am essentially trying to "flatten" the specification as much as possible, so that it won't feel like you are manipulating an XML tree. ...
16
votes
5answers
3k views

Do enums create brittle interfaces?

Consider the example below. Any change to the ColorChoice enum affects all IWindowColor subclasses. Do enums tend to cause brittle interfaces? Is there something better than an enum to allow for ...
1
vote
1answer
104 views

component-based power system for a game [closed]

My issue is that I've been trying to implement a power/electrical system for a while now. I'm using Unreal Engine 4 with C++ but that's not really relevant. I'm trying to implement some sort of ...
1
vote
1answer
81 views

Experiences with C++ Async/actor model Library [closed]

I am fairly experienced with async and concurrent programming in c# using event, actor, and task based patterns, but now I have a task in c++ with which I have basic familiarity and it needs some ...
-1
votes
3answers
116 views

Java and C++ connection? [closed]

Quick question about them. Are they semantic kind of way related? I am learning C++ and I want to start java too. Can I get confused when learning the two languages?
3
votes
3answers
315 views

in C++, how to call an 'init' routine as a class is loaded?

I have a program that loads a bunch of "addons" (different meters that measure and display system values). The "addons" have "grown" over time and the code of what addons to "activate", and how many ...
0
votes
1answer
113 views

Best algorithm for “ACM ICPC Team”

I have this problem (complete description): There is a list of persons N and M topics. I have to find out the maximum number of topics a 2-person team can know. And also find out how many teams can ...
-2
votes
3answers
247 views

Programming in Linux (C++) [closed]

So I don't know If this is the right place to ask this. I am new to programming, I am not very in to it (I know classes,arrays,functions..etc(Basic Things)). I was programming with Visual Studio 2013 ...
15
votes
4answers
2k views

Why aren't `void *`'s implicitly cast in C++?

In C, there is no need to cast a void * to any other pointer type, it is always safely promoted. However, in C++, this is not the case. E.g., int *a = malloc(sizeof(int)); works in C, but not in ...
-3
votes
1answer
139 views

Physics/Game Engine in C++ for mobile app [closed]

First post so be gentle. I am a junior seeking a Comp Sci major and was looking into making a mobile game. I wanted to use this for my thesis project next year, and possibly a way to pay back college ...
1
vote
1answer
100 views

Avoiding std::forward and Rvalue References

I recently read the Google C++ Style Guide and especially one part catched my eye. The part about Rvalue References discourages from using std::forward in general and using rvalue references in other ...
-2
votes
1answer
97 views

Is visual c++ cross plat [closed]

Is VC++ cross platform? If, not how can i make it. Should I just use code blocks for cross platform and include any needed dlls in the project? I'm using OpenGL and need to make my game supported for ...