Skip to main content

Questions tagged [c++]

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

2votes
4answers
389views

How to combine multiple functions into a single template based function

Threre are two functions FindMaxDistanceVector and FindMaxDistanceList whose implementation is almost same except some debug information added in FindMaxDistanceList. Note that these two functions are ...
user146290's user avatar
2votes
1answer
201views

Extracting type info

Suppose that I want to implement the following scenario. There is a board and each board has a set of peripherals like leds, temp sensors, gpio and so on. Each of them implements the according C++ ...
bielu000's user avatar
3votes
1answer
214views

Passing info between different branches of a class hierarchy in C++?

So, I have a class hierarchy that looks like this: It is an embedded project, so the entire code will be run over and over. I have several algorithm classes, that compute some result given some inputs....
Rares Dima's user avatar
2votes
4answers
314views

When wouldn't I want to allow polymorphic deletion in C++?

When designing a pure virtual base class (interface) in C++, in what cases would I not want to allow polymorphic deletion via a pointer to my base class? I've seen questions about why you should make ...
ToddR's user avatar
2votes
0answers
223views

How to encapsulate functions inside a library

I'm working on a project that uses an in-house library, which is also used by other projects. There are some classes and methods in other classes that are not used outside the library itself, is there ...
ulitosCoder's user avatar
2votes
4answers
473views

How to avoid 'Call super' code smell with multiple bases having same method name?

According to Wikipedia, Call super is a design anti-pattern in which a particular class stipulates that in a derived subclass, the user is required to override a method and call back the overridden ...
VL-80's user avatar
4votes
1answer
255views

Refactoring a codebase from manual memory management to RAII

Edit: @Ben Cottrell's comment said this was similar to a question about spaghetti code. While both questions involve large codebases, mine addresses a specific technical pattern: manual memory ...
Arno's user avatar
  • 151
0votes
2answers
177views

Interface with member interface?

Let's say I am coding an C++ application which needs to drive some motors with some hardware interface (USB, Serial...). There are several kinds of motors, which expose the same services, but with ...
Oodini's user avatar
4votes
3answers
3kviews

Remove a loop, adding a new dependency or having two loops

I'm developing a game with C++ and Unreal Engine 5.4.4. I currently have a problem on how to remove a loop without having to add a new dependency to a module. Unreal has modules for grouping related ...
VansFannel's user avatar
0votes
2answers
135views

Leveraging Qt models for nested data structures

Here is a simplified version of what I'm trying to achieve. For every Store that is added, one or more Departments can be added. For every Department that is added, one or more Employees can be added. ...
19172281's user avatar
3votes
3answers
216views

Best Practices for loading primitive data types from raw bytes

On occasion, it is very useful to reinterpret raw bytes structured data - ints, floats, etc. Eamples include reading from a mmapped file, reading some sort of in-memory data frame, or other tasks that ...
Alecto's user avatar
1vote
3answers
262views

How to allow users to provide their own child classes in a factory design pattern in c++?

I am building a c++ project that will allow users to essentially model and create their own fleet of cars. Right now, the approach I have in mind is a Car Factory Class that will implement all of the ...
J K's user avatar
  • 27
4votes
1answer
242views

Are contiguous objects contiguous in virtual memory or physical?

More or less what the title says. Suppose we have a sequential container like vector in c++ that will store data contiguously. When we say that the data is stored contiguously do we mean that it's ...
codefast's user avatar
0votes
2answers
213views

Help with optimizing virtual method

I am developing a key / value database https://github.com/nmmmnu/HM4 Currently I have following commands XNSUM - sum keys with same prefix XRSUM - sum keys from some range XNCOUNT - count keys with ...
Nick's user avatar
  • 305
0votes
2answers
174views

Designing a Two-Party Protocol

I want to design a two-party protocol that runs on two different processes; each process is one party of the protocol. My implementation of a Protocol looks as follows: enum class Role { P1, P2 }; ...
Mahyar's user avatar

153050per page
close