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

learn more… | top users | synonyms

1
vote
0answers
89 views

How to extract the active code path from a complex algorithm

I have been puzzled lately by an intruiging idea. I wonder if there is a (known) method to extract the executed source code from a large complex algorithm. I will try to elaborate this question: ...
2
votes
1answer
285 views

When not to move a “C style” code to “C++ or Object Oriented” code?

Context I am (part of team A) developing a piece of functionality which depends on new APIs provided by team B. Old APIs (also provided by Team B) are there and this is how they are being used in our ...
1
vote
1answer
171 views

What sort of information can I extract out of a dll file? [closed]

I was dealing with a virus earlier today which was a .dll file disguised as RUNDLL.dll which is regularly seen in the task manager and launches on startup. I would like to know how much information I ...
25
votes
7answers
2k views

Disadvantages of scoped-based memory management

I really like scope-based memory management (SBMM), or RAII, as it is more commonly (confusingly?) referred to by the C++ community. As far as I know, except for C++ (and C), there's no other ...
-1
votes
1answer
89 views

Size of objects during Multilevel inheritance [closed]

Below is a pseudo declaration for a multilevel inheritance. Base class ( protected int data) derived1 : virtual public base ( protected int data1 ) derived2 : virtual public base ( protected int ...
3
votes
2answers
198 views

Multiple entrance points in project

My question is related to C++ but it comes from Java actually. When I was programming Java I had multiple classes, which were derived from a base "Test" class. Their purpose was to test things - run ...
1
vote
1answer
115 views

LLVM case: is the success due to the algorithms? [closed]

I'm not sure if this is a subjective question, I hope not but I'm not proficient with LLVM so I'm just wondering: how come it's become so popular and so widespread used in the industry? Were the ...
0
votes
4answers
343 views

How do I deal with global variables in existing legacy code (or, what's better, global hell or pattern hell)?

So... We have this fairly big project (~5k LOC, but there's duplicated code so it's hard to tell) with literally hundreds of global variables. The project has more dependencies on other projects, and ...
9
votes
4answers
918 views

Why do all <algorithm> functions take only ranges, not containers?

There are many useful functions in <algorithm>, but all of them operate on "sequences" - pairs of iterators. E.g., if I have a container and like to run std::accumulate on it, I need to write: ...
10
votes
4answers
674 views

What are the problems of bringing C++-like const into a language?

I am interested in the idea of C++-like const not that particular execution (like casting away const). Take for example C# -- it lacks C++-like const, and the reason for it is the the usual -- people ...
0
votes
1answer
558 views

Is this proper OO design for C++?

I recently took a software processes course and this is my first time attempting OO design on my own. I am trying to follow OO design principles and C++ conventions. I attempted and gave up on MVC for ...
1
vote
4answers
173 views

Learning programming from a book which uses C++98 [closed]

I am learning programming from a book called "Programming Principles and Practice" by Bjarne Stroustrup. It has been highly recommended over here and elsewhere. My only issue is that it uses C++98 and ...
1
vote
0answers
150 views

Binary Tree/Knowledge Base design C++

Currently I have a binary tree template setup where my main is using it with strings to make a question/answer game. I'm using a knowledge base that works as an interface to the binary tree that main ...
-1
votes
2answers
258 views

C#/C++ GUI development without drag and drop? [closed]

I'm currently programming Java, I have played around with C++ before, but I have never touched GUI as I feel "cheat-like" when using its drag and drop system. I feel good and enjoy programming my own ...
25
votes
3answers
1k views

Why does the boolean type in C++ support `++` but not `--`?

Why does the operator -- not exist for bool whereas it does for operator ++? I tried in C++, and I do not know if my question apply to another language. I will glad to know also. I know, I can use ...
0
votes
2answers
169 views

Shared source file between two parts of project [closed]

I have the following sort of directory structure: part1 build src part2 build src Now I have a header file that I would like to include in both parts of these projects, it will ...
3
votes
2answers
219 views

Speed difference between VM-based and compiled code [closed]

Not so long ago I was told by a senior academic that, these days, VM-based code could run nearly as fast as compiled code, but my own experience is that compiled code runs several orders of time ...
1
vote
1answer
129 views

Chained ruleset parsing and evaluation code: recommendations?

So I have to write a filtering system, which may apply preprocessed ruleset to data - and trigger some actions defined in the ruleset while continuing its evaluation. <ruleset name="1"> ...
7
votes
4answers
697 views

Apple eating problem

Player A and Player B play a game. On the middle of the table there is a pot full of N apples of different weights. Player A starts first and choose an apple and start eating it. Losing no time player ...
0
votes
2answers
146 views

In C++ what is the commonly accepted method for making a program platform-agnostic? [closed]

The way I usually do it is I make some namespace Platform in Platform.h and every OS call is encapsulated by a static function in this namespace. So the only place in the entire code base that knows ...
5
votes
3answers
223 views

Member functions vs. Non-member functions for math operators

I'm writing a linear algebra library (long story short, it's a school assignment) that involves matrices, vectors, etc. In the process of creating this library, I'm going to be creating functions ...
0
votes
2answers
299 views

How do programs like JAVA and C++ store variables in a database , does it still use MySQL like in PHP? [closed]

I imagine they have to have some sort of query to goes to a database , or maybe I'm wrong and they can just store it to their computer? Is MySQL for server - side scripting only?
0
votes
2answers
88 views

Design principles : classifying different types of class [closed]

I'm trying to clarify the design of a C++ application, and would like to define a clear classification among classes to aid clarity. However I'm struggling to find any literature to help me, probably ...
1
vote
3answers
123 views

C++ project organization to reduce unit testing build time

I want to organize tests for a project large enough that build time matters (especially for the CI server). Say I have this code that I would like to test : //foo/greet.cpp #include <stdio.h> ...
1
vote
0answers
59 views

On the process of replacing an internal framework by a public one [duplicate]

I am working on several applications which depends on a framework which was developed by a prior engineer in the company. The framework was mainly developed and maintained in the early 2000s, and ...
1
vote
1answer
194 views

Running a process multiple times at the same time

I have a c++ program with opencv library which takes an image as input and perform pose estimation,color detection,phog. When I run this program from the command line it takes around 4-5sec to ...
0
votes
0answers
20 views

Offload traces into shared memory

There is a task to trace thread execution activity for posthumous analysis with minimum impact on latency/performance. Stack trace might be not enough to understand the reason of crash. Initially I ...
1
vote
1answer
66 views

How to convey lifetime requirements?

Usually I use std::unique_ptr to convey ownership and pass in raw pointers as parameters when no ownership is implied. However, I almost never consider a nullptr to be acceptable as an argument, so it ...
1
vote
2answers
117 views

How to manage focus for a small set of simple widgets

I'm developing a set of simple widgets for a small (128x128) display. For example I'd like to have a main screen with an overlay menu which I can use to toggle visibilty of main screen elements. Each ...
2
votes
2answers
225 views

Doing work in vector's push back

I often use the following syntax: std::vector<foo> vec; vec.push_back( someClass.getFoo(...).modifyAndReturn() ); Considered about exception safety, I quote the standard on vector's push back ...
1
vote
1answer
166 views

Are there advantages to declaring stack variables constant in C++

It's not clear to me what benefits there are of declaring your stack variables as constant in C++, I was hoping somebody might explain the benefits and purpose for this technique. For example: void ...
-1
votes
2answers
237 views

Why can't there be more than one destructor in a class in C++ [closed]

Destructor usually free the memory. And i think that one destructor is enough and there is no sense of keeping multiple destructor in C++. But The question is why can't we just write multiple ...
0
votes
3answers
263 views

How does assembly relate to machine/binary code

How does assembly relate to machine/binary code. For example here is how to print to the screen in mikeOS(a small pure assembly OS), mikeOS it uses NASM to assemble. BITS 16 ORG 32768 ...
4
votes
3answers
364 views

What are my options for using a C++11 library in a C# WPF application? [closed]

I am writing a cross-platform (OS X and Windows) desktop application in C++11. I intend to use the same C++11 core on both platforms, utilizing native frameworks for the UI (Cocoa and Objective-C on ...
-1
votes
1answer
111 views

Live share prices for a side project [closed]

Me and some of my friends would want to start a side project which we will work at our spare time. Here is our criteria 1) A challenging project which will teach us skills which has business value in ...
1
vote
2answers
207 views

Choice between 1-dimensional and 2-dimensional array

I'm implementing the Chessboard class to represent the chessboard. I've to implement the transformations (reflections and rotations) on the chess board possible. The possible transformations includes ...
0
votes
1answer
103 views

How to provide a custom ID to a downloadable application?

I've noticed that with remote support services, a technician usually sends you a download link to an executable. When you click on that link, it installs a software which automatically connects with ...
1
vote
2answers
116 views

Data retrieval and indexing

I have around 800,000 rows of data stored in the boost shared memory from the database. The data are in the form: Id Color Length Size 1 1 2 ...
2
votes
2answers
223 views

Trying to get a better understanding of object-oriented design's performance pitfalls

I'm currently in a high-performance computing class taught in C++. Usually, I do work in C#, meaning everything is taken care of for me, and optimization comes behind maintainability and higher-level ...
0
votes
4answers
274 views

Binary Search seems superior, why did the committee of C++ still have Find in the algorithm library?

I wish to search for an integer in a vector of integer. I have two candidates for the job: Binary Search Find It seems that Binary Search is the best candidate for the job as although I have to ...
0
votes
1answer
102 views

Is TCP message order still guaranteed when using async IO

Here the scenario I'm imagining. Two messages are transferred, both will require 2 packets each (I know you don't deal with packets directly with TCP, but on the IP level each message will consist of ...
0
votes
2answers
149 views

How do I pass a variable's value from one class into another? (C++)

I have a class ("Class A", we'll call it) which calculates the value of a private variable (which we can call numLoaves) with a public function. I need to use the value of numLoaves in a public ...
0
votes
6answers
489 views

Coming from high-level to C [closed]

I have a web background that grants me basic understanding over programming. Some older kids wouldn't even call that programming knowledge ("any moron can do PHP/Python/Ruby"), I guess, but let's not ...
1
vote
1answer
223 views

Implementation of deque in C++ with an array

How is the end() function implemented in deque-STL of C++ with array? As per my knowledge it returns past-the-end element. But when a loop is run like, for(i=deq.begin();i!=deq.end();i++) and the ...
1
vote
2answers
252 views

Decouple GUI & Program logic

I have some windows c++ code (pure winapi c++, no MFC etc) that I would like to build a GUI for. My code does not know about windows GUI, it is completely decoupled from any type of UI. The question: ...
1
vote
2answers
111 views

Maintaining independence between modules

I am reading Algorithms 4th Edition by Robert Sedgewick and in chapter 1.2 it discusses API design. It says: "The key to success in modular programming is to maintain independence between modules. ...
-1
votes
1answer
87 views

C++ program compiles fine, but I get a number of odd errors at runtime [closed]

So I've got a little experience in java, and recently I thought it would be nice to branch into c++. I've done a little programming in it, but I still know very little about the language. Recently, I ...
1
vote
0answers
117 views

How to organize points on a sphere in bins and navigate between bins?

I'm having trouble coming up with a suitable way to navigate through a set of star coordinates in the Equatorial Coordinate System. My goal is to display those which are within a given range of ...
1
vote
2answers
177 views

Large number of projects for a single application

I'm working on 300K line C/C++ Windows application that is spread across 23 different Eclipse projects (approximately one third for Qt interface, one third for DLLs and one third for static ...
14
votes
2answers
613 views

Which is better: a bunch of getters or 1 method with a selection string parameter?

Our knowledge domain involves people walking over a pressure-recording plate with their bare feet. We do image recognition which results in objects of the 'Foot' class, if a human foot is recognized ...