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

learn more… | top users | synonyms

-3
votes
0answers
35 views

Help with SIMD algorithm implementation [on hold]

Hello guys i am really stack i need to implement matrix multiplication algorithm using SIMD but I don't know too much of c or c++ and i am having a bad time looking for a library with good ...
8
votes
1answer
6k 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 = ...
50
votes
9answers
38k views

std::shared_ptr as a last resort?

I was just watching the "Going Native 2012" streams and I noticed the discussion about std::shared_ptr. I was a bit surprised to hear Bjarne's somewhat negative view on std::shared_ptr and his comment ...
0
votes
1answer
46 views

Linked list pop_back implementation ignores pointer-to-nullptr

Let's assume I'm only allowed to use new and delete and no smart pointers in my implementation. I am not using sentinel nodes. Below is my implementation for pop_back: void sLinkedList::pop_back() { ...
48
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 ...
-5
votes
1answer
58 views

what to ask for from developer while delevering ios and android app? [on hold]

I am outsourcing a productivity app on android and IOS. however, I want to be able to maintain and update the app with an in house team after I receive the final version. what shall I ask from the ...
0
votes
1answer
84 views

Syncing data from memory process (C++) to database

I have a C++ program that read game data from memory process. For example, int points = 0; while (1) { points = ReadProcessMemory(..) // points will be read from game's memory Sleep(100) // Don't ...
7
votes
1answer
168 views

Can the C++ template system be used to perform type safe operations of the relational algebra

Assume that the parameters of functions representing operations of the relational algebra are represented by individual types: structs or classes. An operation such as (natural) join will have ...
1
vote
1answer
73 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 ...
0
votes
0answers
36 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
49k 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
342 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
362 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 ...
1
vote
1answer
123 views

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

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
156 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
281 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
87 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
21 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
873 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
60 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
55 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 ...
3
votes
7answers
555 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
95 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
72 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
53 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++ ...
-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
216 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
55 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
346 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. ...
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
105 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
168 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
147 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
156 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
790 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 ...
-2
votes
0answers
32 views

How to combine SDL and OpenCV together to build an app? [closed]

I want to make a simple game in which the user will pick up a block using hand gesture and put it on the other side. How to make such a small game on ubuntu? What tools/libraries will I require? How ...
0
votes
2answers
85 views

What are the prerequisites to start with OpenCV in C++?

I'm an intermediate C++ programmer. Do I need any math knowledge in order to build computer applications using openCV?
4
votes
5answers
199 views

How to store math expression in c++ list

I am parsing a infix math expression to a postfix form. I want to store it in a list like [4.5, 3, 0.25, +, -] so that I can process it once it's parsed. I could store it in a string again, but I ...
0
votes
0answers
50 views

Should frequent Fonts, Colors, Pens etc be “Cached”

I am creating a game, currently everything redraws every 50ms, and that involves quite a few Gdi Objects. Here: Gdiplus::Pen outlineScrollPen ( Color (200, 0, 0, 0), 4 ); ...
1
vote
2answers
106 views

Ideal OOP Design

After learning OOP design then I got to know my programming way was not correct. One should convert physical entities or logically separable components into classes which are reusable and have their ...