Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c++]

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

2
votes
4answers
799 views

Is “Let more people able to review” a valid reason to “write c++ as if Java” at some degree?

According to Should we avoid language features that C++ has but Java doesn't?, I know it is horrible to write C++ as if Java, mostly because it drops the beneficial features of C++ languages. But ...
10
votes
5answers
6k views

Is passing arguments as const references premature optimization?

"Premature optimization is the root of all evil" I think this we can all agree upon. And I try very hard to avoid doing that. But recently I have been wondering about the practice of passing ...
0
votes
1answer
665 views

Using a macro for a libraries namespace?

In some code bases (such as hydra, and thrust's tuple implementation) I see namespaces defined entirely with macros. It appears the reason for this is so that you can configure the namespace to your ...
1
vote
1answer
213 views

Is it wrong to prefer exceptions to centralize error handling logic?

Using C++, often I hear that you should avoid throwing exceptions for flow control and you should avoid calling functions in conditions where you know they will throw. For example, if a function ...
-2
votes
3answers
146 views

Platform independant ways of passing messages between executibles

I am working on an a data collector which could be called an API of some sorts, which is based on .Net Core 2.1 . It's job is to receive and pull (ask for) data from data collectors(executable, DLL,...
2
votes
3answers
707 views

High level overview of how printf() works with Windows OS

I asked this question on an IRC channel, sadly I am going around in circles. I am aiming for a high level overview (but with some technical details if necessary) on how a function such as printf() ...
2
votes
2answers
197 views

Designing a Way for Process to Communicate with Kernel

I've got a project that is sort of a virtual operating system. In this project, the Kernel class is responsible for creating Process classes. The process class consists of Thread classes and the ...
1
vote
1answer
171 views

Limitations of using classes as interface

I am an Electrical Engineer now training and working as an embedded software developer, so I have little formal computer science and software design training. I have until a few months ago only worked ...
0
votes
1answer
269 views

Advantage or disadvantage of using = operator or uniform initializer while using auto keyword

Most examples of auto use the = operator. #include <iostream> int main() { auto a = 1; std::cout << a << '\n'; } Why don't they use the uniform initializer like this? #...
24
votes
7answers
10k views

Should the STL be avoided in large applications?

This might sound as a weird question, but in my department we are having trouble with following situation: We are working here on a server application, which is growing larger and larger, even at the ...
3
votes
1answer
475 views

How to deal with large source codes?

Maybe this answer already exists here, but I do not know if there is any technical term for that. I'm starting to develop in C ++ and as the program grows in size, it gets harder to move through the ...
7
votes
3answers
445 views

Where should I put my enum classes?

I have some code that looks like this: // Player.hpp class Player { public: enum class State { RUN, WALK, STAND }; }; The enum class State is used by the Player class, as well as by many other ...
3
votes
3answers
168 views

How to separate serialization, visualization and computation from GUI editable code objects?

This might be an X Y problem, but here's my situation. I've got a QT5 C++ code base whose task it is to allow for the configuration of a "process chain". A "process chain" here means a list of ...
-1
votes
1answer
226 views

Does it make sense to iterate a ranged for loop using constant reference here?

I have the following code, and I was wondering if I'm optimally iterating through my ranged for loop: struct data_type { int a; int b; }; int main() { // Assume I have initialized a ...
-4
votes
1answer
349 views

TIOBE Index: why c++ is in 3rd place and C is having more land in the last year?

Searching for c++ ranking on the TIOBE index, I was stumped to see that C is in front of C++, and from 2017, C took a leap. Could someone explain why?
7
votes
7answers
2k views

Best practice to “continue” from inside a nested loop?

Here is a simplified sample. Basically, it does checks on a string from a string list. If the check passes, it will remove that string (filterStringOut(i);), and it is no longer ...
2
votes
2answers
255 views

(Style) “Good” way of dealing with flags/options

So I've seen many different methods used for this in different librarys, and I want to get a sense of which one may be preferred (or perhaps it's strictly personal preference/case by case). Just as an ...
1
vote
2answers
200 views

Large matrix manipulation in multithreaded environment

I have: matrix 20*40000 of floats M - std::vector<std::vector<float>>; 1000 values X; ~2000000 POD structures S. A typical situation is: for each value from X I take several structs from ...
1
vote
1answer
832 views

Difference between header files and interfaces

I wanted to know whether the header files in c and c++ have same function as that of interfaces used in Java? If not what is the difference between header file and interface?
2
votes
0answers
2k views

How to improve a pattern 'enum class with methods'

Over many years, I always find myself reconsidering this design, so I wanted to get some feedback on my solution to it. Problem: I need a limited amount of objects = instances from a class, and I ...
5
votes
3answers
1k views

Moving from Qt/C++ to C#/WPF - Productivity Gain?

I created a small Desktop application (approx 15000 lines of code, so not that large) written in C++/Qt. This is non-commerical, just a hobby project and I am coding on my free time. The larger the ...
-2
votes
2answers
129 views

How to call more than one program from a single process in an efficient way?

i want to call more than one process from the main program which is written in C++. how to call them with the most efficient way given that one process may open and close more than one time. the ...
1
vote
2answers
179 views

Picking a concrete type based on a configuration parameter

I have a code base that contains several different instances of the following pattern, the key point of which is that the concrete type of the class is decided at run time based on a string from a ...
1
vote
2answers
205 views

Does increase of number of classes have impact for performance

I'm in the middle of refactoring a project (in C++11) and I'm struggling with a decision is it good to change huge enum with about 100 record to separate classes. This enum is used in about 4 places ...
5
votes
3answers
1k views

What is the correct approach to test classes with inheritance?

Assuming I have the following (over-simplified) class structure: class Base { public: Base(int valueForFoo) : foo(valueForFoo) { }; virtual ~Base() = 0; int doThings() { return foo; }; ...
7
votes
2answers
355 views

FIFO Min-Max-Heap for Rolling Median

I'm working on a system with hard real-time constraints in c++ and I need a very fast way to calculate the rolling/moving/streaming median of a set of numbers of size N=100 to 300. Normally this size ...
0
votes
2answers
432 views

What is the safest practice in handling QWidget pointer lifespan in a QObject oriented environment?

Consider the following constructor: NetworkTools::NetworkTools(QObject *parent) : QObject(parent) { view = new QWebEngineView(); view->setParent(parent); // Produces an error, shown below. ...
-1
votes
1answer
162 views

Multi module project version management

I have a CMake multi module project made of a library and an executable. Both the root project and each sub module has its own version (major.minor.patch). I would like to know how to handle each ...
2
votes
2answers
167 views

Object set-up for testing: Manipulate the object or use its functions?

Assuming I have the following (very simple) class class Foo { public: void setAB(int a, int b) { m_a = a; m_b = b; m_aIsBigger = a > b; } int getA() const { return m_a; } int getB() ...
0
votes
3answers
3k views

C++ design - vector classes with different element types

I am trying to design a group of related classes. For example: one table class holds a vector of integer, and has a function returning integers from the vector another table class holds a vector of ...
0
votes
0answers
115 views

A program, written in native code, needs to access data, read by a managed DLL

I'm working on an application, which needs to base itself on a DLL, written in managed code (C#), in order to function. That DLL contains type definitions. Therefore a convertor has been written, ...
3
votes
4answers
249 views

Design two classes that are closely related

I have the following basic design points: Let's say I need to design 2 entities, ADecoder and BDecoder, which are almost the same, except for few details. Let's say both have a function decode() ...
0
votes
0answers
36 views

Model-View in Qt app with device access

I'm building a monitoring system that, well, monitors a series of devices, periodically requesting various kinds of information to each device, such as current status, networking information and the ...
3
votes
1answer
185 views

Best practice for grouping related constants

I'm working on Finite Element code in MATLAB, and the number of constants (for instance user input defining the geometry, physics, numerical solution scheme) is substantial. Currently, I've been ...
6
votes
2answers
302 views

Abstraction of VAOs, VBOs and Models

I have gone down the rabbit hole that is abstracting away a working game engine in OpenGL and C++. Before reaching the other side I'd like to ask about my current design, which is - the more I look at ...
0
votes
1answer
96 views

Name of different patterns of acting on data in libraries.

I contribute to a couple of open source software, and I've noticed two types of patterns when classes act on data. I am interested in the name of these patterns. The first is something that goes ...
0
votes
2answers
153 views

Manage the Lifetime of GUI States

I am designing a program responsible for a GUI (with the graphics and user input being managed within a typical update loop) which has several states: The default state is an animation which ...
1
vote
3answers
185 views

Class invalid flag vs exception

So i have the following. I read in lines from a text file. Each line needs to be analysed and get the important data extracted (I wont go in the details here). I worte a Parser class which does this ...
-1
votes
2answers
139 views

Solutions for preventing build breakage

Some background to my question: We have a traditionally windows-only C++ code-base which we are in the process of porting to linux. Parts of the system have been running on linux for many years, but ...
1
vote
0answers
293 views

Inter-system communication design on Windows (C++)

I was wanting to create a program consisting of 3 elements: A central component with no UI which will work on HTTP traffic and trigger one or more “worker” elements as needed A monitor component ...
0
votes
1answer
211 views

Passing data to an unknown variable

I am developing a project that uses serial communication to interface between a micro-controller and my computer. I want to be able to pass what variable I want to change as well as the data to be ...
-1
votes
2answers
309 views

How to port gcnew and gcroot from Visual C++ to gcc [closed]

I have the task to port some code from Visual C++ to gcc. Some calls are gcnew and gcroot to handle managed code inside cpp module. How can these calls be ported to gcc in a fashionable way?
0
votes
2answers
117 views

Version checking when reading deeply nested structures

I need to open a game save file, read it, maybe modify it and then save it. The structure of the save is quite simple: it is an object with some members, some of which are data, while others are ...
102
votes
10answers
18k views

Is it ok to use meta-programming even though not all of my colleagues understand it?

I employ a lot of meta-programming to avoid repetitive tasks and build safer-to-use abstractions. I recently moved to a new job where I am working in a larger team and this worries some of my ...
-3
votes
1answer
808 views

c++ - implimenting an in memory database [closed]

I'm practicing various C++ exercises. In this particular exercise they are asking me to implement an in memory database. I guess they are not asking me to use something like SQLlite. Could anybody ...
0
votes
1answer
211 views

Relative merits of monolithic repository over multiple smaller ones

I was tasked with implementing a networking stack. The software is self-contained with no external dependencies - it only needs the C++14 standard library, and a POSIX platform. In my opinion there's ...
0
votes
1answer
93 views

What are the dangers/downside of unit tested dynamic library(DLL) being different from released library?

This is similar to: https://stackoverflow.com/questions/1278831/unit-tests-in-production-release-code# but more specific. At the moment the DLL I ship and the DLL I use for unit testing have ...
1
vote
1answer
138 views

How should end-users install dependencies for software [closed]

Suppose I have an application written in C++, which uses WxWidgets (or some other library) for gui. When an end-user installs my application, how do I make sure they also install the necessary ...
5
votes
4answers
344 views

Return an indicator if the process is succeed or not

I have member function that looks like: Point find_the_special_point(Image img); However, this function may fail to find the point (for example the img does not contain a special point at all). ...
3
votes
5answers
813 views

Fastest way to find all numbers with digits

I have a huge set of over a million numbers of variable lengths. ['773', '2267', '8957251', '170597519', '373590109', '982451707', '999999937', ......] Now given a bunch of digits, say 3 and 7, I ...