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

learn more… | top users | synonyms

1
vote
0answers
9 views

Inner and outer class relationship: should outer class be friend of inner's?

Is this design bad? Does it break encapsulation? The structure class B is a component of class A. Therefore, class A needs access to class B's members. Let a house be class A. Let a housekeeper be a ...
-4
votes
0answers
28 views

c++ osstream not functioning correctly? [on hold]

what is wrong with my osstream info. that I pass through? I am using my written print function, and I think it has to do with the parameters, but I'm not sure. I am printing out student objects in a ...
-4
votes
0answers
19 views

Finite Element Method Reference for C++ [on hold]

I want to learn C++ more deeply. I learned C++ a long time ago and I wanted to refresh my knowledge in doing a project. I would like to create a Finite Element Method application. I searched our ...
0
votes
0answers
25 views

What's an optimal procedure to create a connected cyclic grid of nodes and edges for A* pathfinding

like the title says, I'm trying to create a grid of nodes that hold edges or connections to each other so I can perform A* algorithm to have objects traverse across them as seen in your standard RTS. ...
24
votes
5answers
48k views

What are the fundamental differences between C and C++? [closed]

Many tend to write "C/C++", as if they were the same thing. Although they share many similarities, they are clearly not the same. But what are really the fundamental differences between C and C++? Is ...
2
votes
1answer
336 views

Is it good design to require class users to use Rvalue reference?

I have the following situation where I have a base class and multiple polymorphics derived classes: #include <iostream> class Base { public: virtual void foo() = 0; }; class ...
6
votes
5answers
326 views

If A has B and B holds reference of A, is it a flawed design need to be fixed? [duplicate]

Suppose, I have class Boss and Worker; Boss has a Worker and Worker holds a reference of Boss: Boss.h #include "Worker.h" class Boss{ public: Worker worker; }; Worker.h class Boss; class ...
47
votes
8answers
13k views

What happens to garbage in C++?

Java has an automatic GC that once in a while Stops The World, but takes care of garbage on a heap. Now C/C++ applications don't have these STW freezes, their memory usage doesn't grow infinitely ...
0
votes
1answer
107 views

What are the significant memory management models aside from Java (GC) and C++ (manual approach)? [on hold]

There are at least two distinct memory management models: Java (we do it for you) C++ (it is your responsibility) I have two questions: (1) Is GC language specific or compiler specific? (2) Do ...
0
votes
2answers
138 views

IF statement with OR logical operator

Just a basic question on IF statements in programming languages, specifically C++. Consider the following basic code example: int i = 2; if(i == 2 || i == 4) { //do something } Because the ...
0
votes
4answers
275 views

If of loops or loop with if

Assuming the compiler is smart enough to only evaluate the if in the second example once, which version should one (semantically) use and why? if (b) { for (auto a : as) { foo(a); } } else { ...
4
votes
1answer
84 views

Do I need to declare a delay timer variable as volatile even if I access it from another module

This is a question more about using volatile to prevent optimization than about caching write/read of a variable. Particularly timer delay variables since I don't want to declare everything volatile ...
1
vote
0answers
19 views

Zeromq bidirectional asynchronous transmission?

I have a system which consists of two applications. Currently, two applications communicate using multiple zeromq publish/subscribe sockets generated for each specific type of transmission. Sockets ...
8
votes
5answers
826 views

Techniques for ensuring cross-platform compatibility (C++)?

I was finishing one of my earliest C++ projects which is (according to the framework) supposed to be cross-platform. I developed the project fully in Windows and Visual Studio, thinking that since the ...
1
vote
1answer
59 views

Strategy for Binary File Format Description to C++ Implementation

I am dealing with a lot of legacy, reverse engineered binary file formats, often with lost source code and reading/writing these files needs to be recoded in C++. I am wondering if there are good ...
1
vote
3answers
95 views

Implementing an event scheduler for animations

The basic idea is to have some animated widgets that sit in a container, quite similar to Qt (the only actual difference is that my widgets are animated). The animation is in some cases dependent on ...
0
votes
0answers
51 views

Pointers on porting a c++ workflow domain specific language to javascript

I am writing a game in c++ with the v8 javascript engine embedded in it. I have a c++ workflow system I use to tell things how to do specific things. It's nice and I like it, but I need it to work ...
2
votes
7answers
545 views

C++ delete vs Java GC

Java garbage collection takes care of dead objects on the heap, but freezes the world sometimes. In C++ I have to call delete to dispose a created object at the end of it's life cycle. This delete ...
2
votes
1answer
94 views

Writing a non-monolithic database wrapper

I have a SQL database to which I store and from which I read several objects into my C++ code. I wrote a single database wrapper which handles all the reads and writes to the DB. Of course this ...
0
votes
2answers
71 views

Best Communication strategy for monitoring dashboard

I have a requirement where I need to display certain stats on Admin Dashboard in my web application (Angular+Java). These stats (transnational data) are being generated on different servers (connected ...
2
votes
2answers
1k views

C++ TDD open source projects [closed]

Are there any open source projects out there that are written in C++ in an agile way (TDD maybe)? I am trying to contribute to a C++ open source project in order to catch up with the language and I am ...
-4
votes
0answers
52 views

how to create a pipeline code which interfaces between Borland and visual studio platforms?

what pipeline program will act as a interface between visual basic C++ builder and Borland 5.0 they must fulfill these- a C/C++ code which will be a pipeline method interfacing between C and C++ ...
-3
votes
1answer
66 views

Trying to create simple quiz in c++ [closed]

I'm trying to create a simple quiz in c++. I want it to be word based but I'm not sure how to do that so I have decided to do the same layout as I did before(when I wanted it to be a word based quiz). ...
-1
votes
1answer
142 views

How to signal a loop to continue the execution instead of using sleep

I am trying to create a thread that will sit and wait to detect new objects in a vector (the queue). Using a loop will crush the resources on the given machine, so I am trying to figure out how I can ...
-5
votes
1answer
208 views

Why code in C instead of C++ [closed]

Why code in C? Isn't C++ basically C but with better features? Why do people still use C? Would it be easier to make a game with C or C++?
1
vote
1answer
54 views

Chain accessors or return the value of private pointer

hopefully the title isnt too confusing, I am having trouble thinking through what best-practice dictate I do in this situation. Say I have the following class structure Class A { public: bool ...
3
votes
3answers
8k views

Is there still any value in learning assembly languages today? [closed]

Specifically for a game programmer. If you really needed some assembly routines you could look for help, whereas back in the 80s/90s it was one of the mainstream languages. I read that compilers can ...
4
votes
4answers
339 views

Are there any alternatives to dependency injection for stateless classes?

I am working on an application whereby I have designed classes to fit into several groups: Immutable: initialised through constructors, uses copy-and-swap idiom (inc. move), can deep copy (i.e. ...
-2
votes
0answers
76 views

What does a framework need to be good? [closed]

So I didn't know what type of way to represent this question or where to post it, but I thought this would be a good place to start. So all current day frameworks have loads of features, loads of ...
1
vote
1answer
159 views

is this a good design

For example, I have a clan and a character. There's a character that is the leader. To give the clan a specific feature, some money from the character is required. I don't want to have too much tight ...
1
vote
1answer
111 views

Pure abstract classes for input-, output- and bidirectional-pin of microcontroller

I'm writing a real-time operating system for microcontrollers in C++11 - distortos. Currently I'm thinking about a C++ framework for various peripherals. The most basic peripheral which I would like ...
1
vote
1answer
104 views

Using asynchronous calls for heavy IO operation: How to prevent crushing the CPU?

I have an application that reads a large binary file (1GB on average) and compresses into a bzip2 archive. I started out at first compressing these files synchronously, as I didn't want to impede ...
3
votes
1answer
164 views

Potential legal issues with lock-free / wait-free structures / algorithms

While researching the subject matter - lock-free and wait-free data structures - I'm seeing a worrying amount of mention of patents with this area. I've hobby-researched compression algorithms years ...
0
votes
2answers
146 views

Compiling source code using c++

Last year, in university we used the library SDL to create a game from scratch. So I though of developping a game engine based on SDL. I will be using Qt to do the UI and SDL to implement the core of ...
31
votes
12answers
4k views

Is it a code smell to store generic objects in a container and then get object and downcast the objects from container?

For example, I have a game, which has some tools to increase the ability of the Player: Tool.h class Tool{ public: std::string name; }; And some tools: Sword.h class Sword : public Tool{ ...
-2
votes
0answers
30 views

Unable to install opencv 3.1 with visual studio 2013 [migrated]

I downloaded opencv 3.1 (110MB) from the official site and I followed this tutorial and after setting the environment variables and project settings, I always get an error : Link error : Can not ...
19
votes
4answers
6k views

Debugging memory corruption

First off, I do realize this is not a perfect Q&A style question with an absolute answer, but I can't think of any wording to make it work better. I don't think there is an absolute solution to ...
0
votes
3answers
130 views

A few questions about initializing variables

I'm in an introductory programming class and we're only in lesson two, so try to keep terminology simple, ha. I'm a bit confused about when you need to and when you don't need to initialize a ...
1
vote
2answers
453 views

C++, header files and using namespace std

So I understand that one must not use using namespace std; in header files. Well for my assignment we have to overload the >> operator. I got my program to run and all, but I had to include ...
1
vote
3answers
155 views

How do you quickly test C++ code?

I'm working on a series of small projects (~1000 LoC each) on my own in C++. My background is in Python, where I'm used to being able to test out small changes in my code in by loading it into a ...
3
votes
2answers
788 views

How can I “inspect” C++ code?

For reference, I am a JavaScript developer learning C++. The browser is a pretty powerful debugger, and I can easily place a breakpoint in my code, hover over a variable or expression and get the ...