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

learn more… | top users | synonyms

-1
votes
1answer
36 views

execute selection in console in C++ like python or R language

I am started to learn C++ using as IDLE Clion of jetbrain company. Normally using the IDLE of Python (i.e., Pycharm of Jetbrain) or R project i am able to execute selection in console line-by-line my ...
-1
votes
0answers
22 views

Two color bars in one image

Can anyone have idea how to plot two different temperature in same imagesc of MATLAB. Like in the attached figure the blue bar shows temperature range from 0.01*10^5 to 0.1*10^5 K for sample 1 and the ...
-5
votes
0answers
31 views

improve skill to higher and higher levels [on hold]

i have finished several tutorials and online courses for tags programming language. but recently when i go to any interview they asks me about previous and since i am beginner i just had small task ...
6
votes
2answers
311 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: ...
-4
votes
0answers
35 views

E-olymp: Cake. Giving Wrong Answer [on hold]

Cake This is the question. While I am submitting in normal Gnu C++ then it is giving 27% accurate result and when I am submitting in Gnu C++ 4.7.1 then it is giving 8% accurate result?? What is the ...
2
votes
2answers
170 views

How do I make this functional DSL written in an imperative language more efficient?

Suppose I create a simple functional Domain-specific language (DSL) using an imperative language, in this case C++. Here is a simple implementation of a DSL that can has the notion of a simple value ...
-3
votes
1answer
70 views

8 Queens Problem [on hold]

I am trying to improve my knowledge of data structures and algorithms, and have been solving programming problems to accomplish that means. This problem called "8 Queens" seemed like simple iteration, ...
-2
votes
0answers
95 views

What is the meaning of manage c++? [on hold]

What is managed C++?. How does it differ from unmanaged C++?
1
vote
1answer
65 views

What's the quickest and most maintainable way to implement SQL querying of disparate C++ variables?

I've recently joined a team working on radar observations. The team has access to a repository of software (written in C++) used for dealing with these observations, but their work is focused towards ...
0
votes
1answer
18 views

condition_variable::notify_one() thread selection

notify_one() of C++ 11 thread library is used to unblock one of the waiting threads. Question : How notify_one() chooses which thread to unblock ?
1
vote
1answer
67 views

Templating a member name

I'm writing a library that provides graphs for search algorithms. Usually you want to rank nodes using a priority queue. Normally you want to search for an specific node in the queue and lower its ...
1
vote
1answer
197 views

Inserting C++ code into C [on hold]

What I need to do before inserting C++ code into C, and how to do it? Are there any examples to show me how this can be done. I have a good knowledge of C, but never mixed those two. Thanks for the ...
1
vote
0answers
84 views

Software Design, Generic Programming, Physical Devices, and Algorithms in C++ [on hold]

I often have data that in some contexts I want to handle uniformly, but in other contexts I wish to differentiate it. For example, I could have a vector that is series of angles or a series of ...
3
votes
1answer
543 views

Does it make sense to choose UTF-32, based on concern that some basic rule will be broken for UTF-8?

I'm working on an cross platform C++ project, which doesn't consider unicode, and need change to support unicode. There is following two choices, and I need to decide which one to choose. Using ...
3
votes
3answers
276 views

Idiomaticy of macros in C++

Macros are considered a good thing by one and evil by another. Is there a rule of thumb when to and when not to use macros in C++? When are macros idiomatic and when should they be avoided?
2
votes
3answers
374 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 ...
-3
votes
0answers
25 views

Help creating timers (Visual Studio 2013 C++) [closed]

I am working on a project wherein I need to create a "timer". The "timer" runs in a separate program (from the main application the user is "working in"), and therefore, the user will enter the ...
1
vote
2answers
141 views

shared or raw pointer c++

I am developing a noSQL database and currently moving the code from C to C++. It have class Pair, which contains a raw pointer to a memory blob. class Pair { Blob* blob; ... }; Then if you add ...
1
vote
1answer
127 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 ...
0
votes
0answers
26 views

C++ : mixing Directx9 and default windows [migrated]

I am looking for a method of placing a DXLinked window within a windowproc as a child window. This would allow for menus/Forms controls to be externally managed before input to the DX methods. So far ...
9
votes
6answers
918 views

I believe I have mixed C and C++ code when I shouldn't have; Is this a problem and how to rectify?

Background/Scenario I started writing a CLI application purely in C (my first proper C or C++ program that wasn't "Hello World" or a variation thereof). Around midway through I was working with ...
-3
votes
0answers
39 views

Sum of a number and its digits [closed]

So I found this problem on a website and I've been trying to solve it for a few days but I must be missing on something. I work with C++. I need to find the smallest number which, together with its ...
3
votes
1answer
252 views

How do C/C++ programs get ported to different platforms? [closed]

Java applications can run on different platforms because they always run on top of a Virtual Machine specifically developed for each platform. So, there's no native installation, you just drop the ...
9
votes
2answers
520 views

Single-responsibility and custom data types

In the past months I've asked for people here on SE and on other sites offer me some constructive criticism regarding my code. There's one thing that kept popping out almost every time and I still ...
3
votes
5answers
349 views

What are your decision critera in C++ to make something a data member or virtual method?

(Figured this was too subjective for SO, so posting here...) I have some behavior that I can implement in various ways. At least two methods are shows in the code snippet below. Presume that the ...
44
votes
5answers
10k views

Why are there no package management systems for C and C++? [closed]

There are some programming languages for which exist a package management system: CTAN for TeX CPAN for Perl Pip & Eggs for Python Maven for Java cabal for Haskell Gems for Ruby Is there any ...
0
votes
2answers
579 views

Is factory pattern a right pattern for the situation described here?

Is factory pattern a right pattern when we want to consolidate the related objects? Problem - In the Set-top box, I have a user-io, basically the interface to control the settop box - The user-io can ...
3
votes
3answers
168 views

Communication between state machine and GUI

I am writing a finite state machine in C++, designed as a library. Furthermore, I have a GUI implemented as a separate project which needs to update the user interface according to state changes ...
-1
votes
1answer
1k views

GUI-Development with QT for OpenGL/C++/MAC [closed]

I am a complete newbie considering QT. Would you say it is recommendable to use. I would like to build a GUI for my programm. I need about 10 buttons.(Maybe more) It would also be nice to have a ...
1
vote
0answers
92 views

What design pattern best suits managing handles to objects, without passing handles or Manager around?

I'm writing a game in C++ using OpenGL. For those that don't know, with the OpenGL API you make a lot of calls to things like glGenBuffers and glCreateShader etc. These return types of GLuint which ...
11
votes
2answers
3k views

Using a stream manipulator (endl) or a newline escape character (\n)?

I don't have a specific context in which I'm asking the question, but while I was reading a beginner book on C++ I noticed the use of both an endl stream manipulator and a newline escape character ...
3
votes
1answer
70 views

How should one modularly implement related objects?

I tried to make the question title as generally applicable as possible, but I'm not certain I worded it so well. It was brought about by a very specific problem I'm having, and for the remainder of ...
15
votes
4answers
10k views

In C++ why and how are virtual functions slower?

Can anyone explain in detail, how exactly the virtual table works and what pointers are associated when virtual functions are called. If they are actually slower, can you show the time that the ...
14
votes
10answers
2k views

What is the best aproach for coding in a slow compilation environment

I used to coding in C# in a TDD style - write/or change a small chunk of code, re-compile in 10 seconds the whole solution, re-run the tests and again. Easy... That development methodology worked ...
3
votes
1answer
152 views

Providing views to an std::container

I want to maintain a buffer of 5 seconds of sensor data. The sensor data consists, among other things, of accelerometer readings in x,y,z dimensions, gyroscope readings in x,y,z dimension and ...
15
votes
2answers
819 views

Shipping test code. Why wouldn't you?

I would like to ship unit tests alongside a product. Specifically, provide an option so that anyone with a copy of our program can hit a "self-test" button or pass --self-test on the command line and ...
2
votes
1answer
437 views

GUI code implementation for specific Window/Form class

Terminology Element/Form Element -> Fields such as text list, combo_boxes, push buttons, etc. Problem I have a program that is basically a fat client that interfaces into a system that keeps track ...
-2
votes
0answers
7 views

C programming code error [migrated]

So the program is still incomplete, i cant go any further cause there is an error right after the first input, i tried using visual studio 2010 and 2015, both with the same problem: unhandled ...
5
votes
4answers
2k views

What do other languages offer when it comes to infrastructure technology that could indicate its advantage over C in the future?

I have been going through interview questions and I saw one which made me stop and think for a while. It starts with a quote and asks about your interpretation and whether you agree or not. "For ...
0
votes
0answers
19 views

#define as unsigned char [migrated]

I would like to know how can I tell to compiler that a #define is an unsigned char. if #define 1 byte do this: #define AACEESS_PSS 0x80 #define ACCESS_PSS ((unsigned char)0x80) but if ...
2
votes
2answers
107 views

Member and Function Injection in C++ Across Multiple Classes

I have a problem in which a variety of classes in C++ will want some functionality that is neither a "has a" nor an "is a" relationship. The problem is that there are some members with associated ...
-2
votes
4answers
615 views

FizzBuzz on Large Scale

So I was asked to create FizzBuzz at an interview... easy enough. for(int i = 1; i <100; ++i){ if((i%3) == 0) cout<<"fizz"; if((i%5) ==0) cout<<"buzz"; ... ...
2
votes
1answer
74 views

Expandable alternative to Visitor pattern for tree traversal?

I have a tree containing various subtypes of the my base node class. I now want to traverse this tree and do something with the nodes depending on their type. The most straightforward idea is to just ...
1
vote
1answer
79 views

OO Design: Algorithm changing State (Information Flow Question)

I have a class Context, which contains an instance of an abstract class State, which has multiple concrete subclasses (this is an implementation of the State Pattern). Each State subclass executes a ...
1
vote
3answers
525 views

CRM in the context of C++ programming

I was asked by an employer about CRM in the context of C++ software development. The position I was applying for was C++ Software Engineer. I told them: As far as I know, CRM is an acronym that ...
1
vote
4answers
625 views

How should I deal with nested compositions?

I came across the following question on a website for interviews: Here are 3 products: table, chair and bench. Product can be of material: wood, metal, and plastic. Design class structures for ...
3
votes
2answers
98 views

How to setup build system for unit testing + mocking?

We have a legacy code base in entirely C++. Our build system is CMake. My first stab at unit testing was as follows: Define a target (LibraryA). This library contains the code to test. Define a unit ...
6
votes
2answers
1k views

What is the difference between function() and function(void)?

I have heard that it is a good practice to write functions that do not receive anything as a parameter like this: int func(void); But I hear that the right way to express that is like this: int ...
-1
votes
0answers
82 views

reinterpret_cast< > from one structure to another [migrated]

I'm going through a win32 program and I found part of a code contained reinterpret_cast<> from one structure to another. What happens to PKT_HEADER* pPktHeader = ...
0
votes
0answers
79 views

audio file processing in C++

I thought of the following project that I want to pursue: I want to create a C++ program, that can play audiofiles and visualize the amplitudes of individual frequency bands in real time (e.g. with ...