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

learn more… | top users | synonyms

2
votes
6answers
239 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
52 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 ...
-4
votes
0answers
34 views

keep getting wrong answer on uva 1585 score [on hold]

There is an objective test result such as "OOXXOXXOOO". An 'O' means a correct answer of a problem and an 'X' means a wrong answer. The score of each problem of this test is calculated by itself and ...
-2
votes
0answers
20 views

Can anyone tell me what will be the better for Http proxy [on hold]

I have assignment based on computer networks I have to design a Http Proxy Server but I am confused that whether I should build it on java or C#. Please guide me and also explain why it is good ...
2
votes
0answers
59 views

Can't figure out class scheduling issue? [on hold]

"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 ...
-1
votes
0answers
88 views

I study c++ constantly but no idea to make [on hold]

Hi I'm student in highschool. My favorite language is C++ and I love it. And I try to study alot(recently reading EMC++ or template or else) I want to make some program but have no idea what to make. ...
-1
votes
0answers
62 views

How do you recognize when topological sort shoudl be used? [on hold]

What are the general properties of a programming problem that hint to the necessity of topological sort?
0
votes
1answer
75 views

Receiving information from another application [on hold]

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 ...
-6
votes
0answers
76 views

I am new to programming,recommend books and topics to cover to become a better programmer [closed]

I am 18 and started coding now which I really feel is late,coming to the topic.I just quit my college I am interested in creating bots,forums and website building and even building Android and I phone ...
0
votes
1answer
94 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
75 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 ...
-3
votes
1answer
79 views

I want to know how to code graphics in c++ [closed]

It doesn't matter what graphics. Just some that could work for the compiler code blocks 8.1. #include <graphics.h> This graphics.h Sounds good but I don't know how to use it. Help would ...
-4
votes
1answer
41 views

C++ how export variable from a dynamic library? [closed]

I have an API class: API.hpp (public API) class math { static __declspec(dllexport) double Pi; static __declspec(dllexport) double Sum(double x, double y); }; Dll.cpp (test.dll) ...
-3
votes
0answers
32 views

Text UI strategy game: Which Language/engines? [closed]

I'm thinking about building a simple 2d strategy game, the likeness of starcraft, except extremely simplified. The main thing I want to do is have a text UI, the kind of thing you see when you ...
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
259 views
+100

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
161 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
363 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
178 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 ...
156
votes
9answers
10k 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
906 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 ...
-3
votes
0answers
36 views

3-Tier architecture - Object Relation [on hold]

I have some question about the 3-Tier architecture : Relation between Business Object and Manager If my master object (example : character) have a relation with another object (charater_stat, ...
2
votes
3answers
261 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
54 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
207 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
339 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
199 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
108 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
172 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
133 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
156 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
71 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
103 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
78 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
114 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
314 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
110 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
137 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
98 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 ...
0
votes
1answer
120 views

How can frond-end developer support different encoding (UTF-8 , UTF-16,..)other than ASCII? [closed]

I'm writing simple language compiler frond-end (based on LLVM) in C++, and I wonder how could language support encoding stuff? How can I (as compiler writer) support encoding? I need to know the ...
3
votes
1answer
286 views

raw, weak_ptr, unique_ptr, shared_ptr etc… how to choose them wisely

There is a lot of pointers in C++ but to be honest in 5 years or so in c++ programmation (specifically with the Qt Framework) I only use the old raw pointer : SomeKindOfObject *someKindOfObject = ...
0
votes
1answer
74 views

Adding permanent objects to a vector

I'm relatively new to C++ (coming from Java) and I've got a little problem regarding lifetime of objects. My situation is like this: I'm having a class A in which I'm trying to add elements to an ...
1
vote
1answer
118 views

Polymorphism Question

For the sake of the question I've taken this code from http://www.cplusplus.com/doc/tutorial/polymorphism/ class Polygon { protected: int width, height; public: void set_values (int a, ...
1
vote
3answers
121 views

Protect memory from a potentially seg faulting function call

How can one safely call a function that might segfault without corrupting the stack or the heap? These SO questions cover using signal handlers and setjmp.h to regain control. Coming back to life ...