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

learn more… | top users | synonyms

0
votes
0answers
7 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 ...
0
votes
0answers
10 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
33 views

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

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
32 views

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

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
28 views

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

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
77 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 ...
1
vote
1answer
108 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
145 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 ...
-2
votes
0answers
140 views

Why do C based languages use a colon for the case's? [on hold]

Why is a colon used at all? For example: switch( c ) { case 'A': CapitalA++; case 'a': SmallA++; default : total++; } Instead of: switch (c) case 'A' ...
-2
votes
0answers
37 views

Find kth smallest element in row wise and column wise sorted matrix [on hold]

One solution I have in mind is that I can construct a min heap of k insert first row/column, then one one by one extract k-1 element from heap and insert new element from corresponding row/column. ...
1
vote
5answers
322 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
165 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 ...
-3
votes
0answers
25 views

Using ftp via ShellExecute()… how to capture (log) output? [on hold]

I'm writing a C++ app that runs an FTP client on files I've created remotely. Current solution is invoking Windows native FTP via ShellExecute() and passing a script for FTP to use to login and fetch ...
156
votes
10answers
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
848 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 ...
-4
votes
1answer
178 views

Why in C# int template/generic parameters were not added? [closed]

A note for CO fans: I am not looking for current opinions, I am looking for historic event, and since it is history, it is a fact now (something that occurred and cannot be changed). C++ templates ...
-3
votes
0answers
32 views

3-Tier architecture - Object Relation

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
253 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
47 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
203 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
337 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
195 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
104 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
132 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
votes
1answer
74 views

How to create a folder in a program's own directory, and create folders in the folders? [closed]

I need my program to be able to create sixteen folders in its root directory where the .exe file is (Windows), and I need each folder to have preceding folders inside that contain more information, ...
1
vote
0answers
62 views

Use of SAL annotations for C++ [closed]

Code analysis tool for visual studio is able to detect some kinds of errors statically if you annotate functions with SAL We used it at first in windows driver when code was mostly C code, and where ...
-2
votes
0answers
56 views

interoperability java and c++ [duplicate]

i want to write a program in two different languages java and c++ that needs a dynamic and interactive communication between its c++ component and java component.i know there is jni and jna for ...
1
vote
1answer
154 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
70 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
101 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
76 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
311 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
107 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
245 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
133 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
95 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
96 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
270 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
73 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
116 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
118 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 ...
1
vote
1answer
131 views

How to make sure that the destructor cannot throw an exception?

I know that we can specify the compiler that a function is not throwing an exception by using noexcept specifier but noxecept functions can still throw exceptions . So, how to prevent destructor from ...
1
vote
1answer
191 views

How to avoid violating one definition rule in this case?

We have an existing Mutex C++ class. It has a debug feature to track the owner thread id. So it has a member variable to store this, but because the original developer doesn't want to waste memory, ...
4
votes
2answers
345 views

Const means Thread-safe?

I was put onto this video: http://channel9.msdn.com/posts/C-and-Beyond-2012-Herb-Sutter-You-dont-know-blank-and-blank By http://codereview.stackexchange.com/users/39810/glampert Because I asked ...