Questions tagged [c++]

C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. This tag should be used for any question which requires knowledge or expertise with the C++ programming language. This is a general tag which is used for any of the C++ language standards (C++98, C++11, C++17, etc.). The question should identify the compiler being used, the operating system, and which of the C++ standards is being targeted.

Filter by
Sorted by
Tagged with
2 votes
0 answers
78 views

C++ Mock Library: Part 6

Parts C++ Mock Library: Part 1 C++ Mock Library: Part 2 C++ Mock Library: Part 3 C++ Mock Library: Part 4 C++ Mock Library: Part 5 C++ Mock Library: Part 6 Side Note: I will say the processes of ...
Martin York's user avatar
  • 94.3k
4 votes
4 answers
3k views

Banking System console app in C++

I built a banking system in C++ (still a lot of features to do but (I decided to post it here to see what can I change so I wont make those mistakes in the future). User header and c++ files Header <...
Ellie's user avatar
  • 347
1 vote
0 answers
52 views

C++ Mock Library: Part 5

Parts C++ Mock Library: Part 1 C++ Mock Library: Part 2 C++ Mock Library: Part 3 C++ Mock Library: Part 4 C++ Mock Library: Part 5 C++ Mock Library: Part 6 Overview So brief overview: Part3 was the ...
Martin York's user avatar
  • 94.3k
8 votes
3 answers
2k views

C++ std::optional implementation

Took a shot at implementing a subset of std::optional functionality. A lot of core features are there but some things like converting constructors, etc are missing ...
jdav22's user avatar
  • 319
1 vote
1 answer
86 views

C++ Structural Requests System with Payload Management

First things first, I'd thank Mr. G. Sliepen and Mr. Davislor regarding their help in the previous questions (C++ System data transfer design) (C++ System data transfer design - Following 1), given ...
Hamza Hajeir's user avatar
1 vote
0 answers
45 views

C++ Mock Library: Part 4

Parts C++ Mock Library: Part 1 C++ Mock Library: Part 2 C++ Mock Library: Part 3 C++ Mock Library: Part 4 C++ Mock Library: Part 5 C++ Mock Library: Part 6 Description: In part 3 I described how I ...
Martin York's user avatar
  • 94.3k
0 votes
1 answer
68 views

Temperature of a Lennard-Jones system

Are the formulas used in getTemperature() and setTemperature() correct? ...
user366312's user avatar
2 votes
1 answer
45 views

C++ Mock Library: Part 3

Parts C++ Mock Library: Part 1 C++ Mock Library: Part 2 C++ Mock Library: Part 3 C++ Mock Library: Part 4 C++ Mock Library: Part 5 C++ Mock Library: Part 6 Define normal use case patterns: The next ...
Martin York's user avatar
  • 94.3k
3 votes
1 answer
65 views

Type-safe number serialization-deserialization

I have written this code for serializing and deserializing integer and floating point numbers to/from vector/array of bytes. The aim of the code is to provide a simple interface to use, but make it as ...
GameRaccoon's user avatar
2 votes
1 answer
65 views

Finding the kth smallest number where all (hexadecimal) digits are different

I'm mostly trying to understand why the simpler char array mask below (to track which digits have been already used) is much ...
Shihab Shahriar Khan's user avatar
3 votes
1 answer
107 views

C++ Mock Library: Part 2

Parts C++ Mock Library: Part 1 C++ Mock Library: Part 2 C++ Mock Library: Part 3 C++ Mock Library: Part 4 C++ Mock Library: Part 5 C++ Mock Library: Part 6 Removing redundant MOCK_SYS usage After ...
Martin York's user avatar
  • 94.3k
6 votes
1 answer
193 views

C++ Mock Library: Part 1

Parts C++ Mock Library: Part 1 C++ Mock Library: Part 2 C++ Mock Library: Part 3 C++ Mock Library: Part 4 C++ Mock Library: Part 5 C++ Mock Library: Part 6 Note: If you see an extra ...
Martin York's user avatar
  • 94.3k
1 vote
2 answers
149 views

Minimalistic implementation of Leapfrog integration algorithm (2)

Please review this C++ listing of an implementation of Leapfrog integration. This C++ listing is rewritten according to this review. ...
user366312's user avatar
13 votes
3 answers
2k views

A Simple Tetris game made with C++ and ncurses

I made a Tetris game with C++ and ncurses. The game implemented the most core rules of the game such as 7-bag system or familiar rules you know about the Tetris, but lacks some features - for example, ...
Doyoung Kim's user avatar
3 votes
2 answers
984 views

C++ std::any Implementation

Took a shot at implementing std::any. I think this should cover a majority of the functionality of the standard version, except there may be some missing auxiliary ...
jdav22's user avatar
  • 319
2 votes
1 answer
110 views

Minimalistic implementation of Leapfrog integration algorithm

Please review this C++ listing of an implementation of Leapfrog integration. Was the algorithm implemented correctly? ...
user366312's user avatar
8 votes
4 answers
2k views

Plotting the Mandelbrot set efficiently

This is my Mandelbrot set program - it includes Smooth Coloring, perodicity checks, and my approach to biomorphs. I know of Edge Detection, but I couldn't find a simple explanation that I can ...
iogamesplayer's user avatar
1 vote
1 answer
55 views

safe numeric type converter

I have written a function for casting between built in numeric types. I built it to check if the source value is within the range of the destination value, and to provide a nicely legible error if not....
Diederick C. Niehorster's user avatar
4 votes
2 answers
108 views

Find largest sum not involving consecutive values

There is a question to basically find the largest sum in an array, such that no two elements are chosen adjacent to each other. The concept is to recursively calculate the sum, while considering and ...
BlazeRod11's user avatar
-2 votes
1 answer
54 views

Market Portfolio Binary Search Tree [closed]

I'm trying to solve the following problem here: First line of input contains the number of days D. The next d lines contains a character c and a number x. If c is B, then buy stock . If c is S, then ...
driver's user avatar
  • 212
2 votes
2 answers
211 views

C++ std::shared_ptr implementation

Took a shot at implementing std::shared_ptr, with a thread-safe refcount and weak count. Didn't do weak_ptr, I'm doing this for ...
jdav22's user avatar
  • 319
1 vote
1 answer
76 views

Process comma separated input and check format

I have to read console input and store data in the vector of structs. In case of any data format violation I have to print "Malformed Input" and return <...
mascai's user avatar
  • 397
4 votes
2 answers
217 views

A memory leak-free RAII wrapper around two raw pointers

As a practice of implementing RAII-enabled class, I prepared a class called DynamicWallet that wraps around two raw pointers. I am well aware that using smart ...
D.J. Elkind's user avatar
2 votes
0 answers
40 views

Reusable storage for array of objects V4

Here is a thirdfollow up on Reusable storage for array of objects, Reusable storage for array of objects V2 and Reusable storage for array of objects V3, taking into account the provided answers. The ...
Oersted's user avatar
  • 299
4 votes
2 answers
535 views

O(nlogn) Lexicographically minimal rotation code but tle on this particular case

Based on a small suggestion here , this code tries to find lexicographically minimal rotation (question) by successively comparing two adjacent substrings in the very left , that can potentially give ...
Aryaman 's user avatar
1 vote
0 answers
49 views

C++ registry class which manages game object, components and systems in an ECS

So this is my header file (registry.hpp): ...
Aspect11's user avatar
  • 145
2 votes
1 answer
96 views

C++ Chess Engine - Initialization of Magic Bitboard Attack Tables

I've just completed the generation of magic bitboard attack tables for bishops and rooks in my C++ chess engine. Main Questions The functions generateMagicNumbers()...
Hunter's user avatar
  • 203
1 vote
1 answer
45 views

Reusable storage for array of objects V3

Here is a second follow up on Reusable storage for array of objects and Reusable storage for array of objects V2, taking into account the provided answers. The following code should be compliant at ...
Oersted's user avatar
  • 299
3 votes
1 answer
51 views

Reusable storage for array of objects V2

Here is a follow up on Reusable storage for array of objects, taking into account the provided answers. The following code should be compliant at least with gcc, <...
Oersted's user avatar
  • 299
4 votes
3 answers
311 views

C++ custom string class implementation

I recently had an interview where I was tasked with implementing a custom C++ string class without using the STL. The interviewer provided the function signatures and variable declarations, specifying ...
Jacob's user avatar
  • 111
11 votes
2 answers
2k views

CAT: Cat Approved TUIs

Cat Hello everyone! I am working on this TUI framework which aims to abstract the ncurses library. I was wondering how understandable it is, and what I can improve! Any feedback is welcome!! My ...
Labricecat's user avatar
4 votes
1 answer
104 views

C++ custom vector class implementation

I've developed a custom vector class in C++, complete with functionalities like assignment, push_back(), emplace_back(), pop_back(), clear(), and size(). I would greatly appreciate any feedback on ...
Jacob's user avatar
  • 111
2 votes
1 answer
40 views

Comparison of Named parameters and the Java Builder pattern in C++

OK writing a C++ wrapper on top of openSSL. Setting up the SSL_CTX* object. There are a whole bunch of extra functions to specify functionality on how this object ...
Martin York's user avatar
  • 94.3k
1 vote
0 answers
56 views

Binary Search Tree Universe

In the world of Binary Search Tree (BST) enthusiasts, where collecting and trading BSTs is a craze, you have a beloved BST with n nodes. In this scenario: (a) Identifying Swapped Nodes and Common ...
driver's user avatar
  • 212
4 votes
2 answers
372 views

Reusable storage for array of objects

My goal is to have a memory pool non-template class that is used to store arrays of objects. The same memory pool object must be reusable for a different array (difference size, different type and/or ...
Oersted's user avatar
  • 299
1 vote
1 answer
112 views

Parsing Tokens in a Toy Interpreter

I'm working on a homework writing a toy interpreter. All the expressions in this language are prefix expressions. The language has a lot of lexical tokens and I wrote code as follows: ...
XuanInsr's user avatar
5 votes
2 answers
540 views

std::chrono compatible clock using CLOCK_MONOTONIC_RAW

We're using std::chrono::steady_clock for most of our internal queues and relative timings. However, we're on a POSIX platform and ...
Ted Lyngmo's user avatar
4 votes
2 answers
79 views

C++ Neuron Spike Raster Deserializer

Please help me establish a solid foundation for this computational neuroscience project. I'd like to make sure I'm moving forward with something reasonable before I begin tackling the more complex ...
Ders's user avatar
  • 43
2 votes
0 answers
74 views

Windows Kernel `vector` class

...
anoncr's user avatar
  • 21
1 vote
0 answers
69 views

An Updated recursive_transform Template Function Implementation in C++

This is a follow-up question for A recursive_transform_view Template Function Implementation and A recursive_transform_view Template Function which returns a view in C++. In those implementations ...
JimmyHu's user avatar
  • 3,974
1 vote
1 answer
75 views

Program to find all possible legal words and their scores in a Wordfeud (or Scrabble) game

To anyone who doesn't know WordFeud, but is familiar with Scrabble, WordFeud is just a variation with different letter bonus placements. The code below is complete and runnable. Given a WordFeud board ...
Cortex's user avatar
  • 440
2 votes
1 answer
50 views

Find perfect and amicable numbers

I've been playing with perfect, amicable and social numbers lately, and created a class for investigating these. At present, it has functions to return the perfect and amicable numbers in a specified ...
Toby Speight's user avatar
5 votes
1 answer
398 views

Print abcabc... in three threads

I want to implement the following case Input - integer number n Start 3 threads. The first thread prints 'a', the second prints 'b', the third prints 'c', then the ...
mascai's user avatar
  • 397
3 votes
1 answer
172 views

C++ Readers-Writer Lock using Asio's Strands

The locking mechanism is implemented in the class RW_Lock. The saved_async_completion_handler structure is used in ...
DeltA's user avatar
  • 133
1 vote
1 answer
52 views

Counting number of time frames in a simulation trajectory file

I have written a function in c++, which accepts an "ifstream" object (file) to read from and a string to match a header token in the file. This way I am counting how many times a token ...
Syed Shuja Zaidi P19PH007's user avatar
3 votes
1 answer
988 views

Knock down tall buildings

I'm trying to solve the following problem: As you know Bob likes to destroy the buildings. There are N buildings in a city, ith building has ai floors. Bob can do the following operation. Choose a ...
driver's user avatar
  • 212
-2 votes
1 answer
57 views

C++ compile time polymorphism example [closed]

I found an example using std::variant to provide compile time polymorphism as a possible optimisation to runtime polymorphism in 'Software Architecture Using C++', https://github.com/PacktPublishing/...
arcomber's user avatar
  • 2,449
4 votes
1 answer
108 views

Packet generation and consumption

I have the following simplification of a program which consists of 2 threads. One thread pushes packets to the back of a deque while another waits for user input before performing a "heavy" ...
Bula's user avatar
  • 379
5 votes
1 answer
398 views

Noughts & Crosses (tic-tac-toe) revisited (using C++20 modules)

This is a development of Nought and Crosses (tic-tac-toe) in C++ a learning project in C++. This time using C++20 modules. As before, any suggestions on improvements in style, clarity (or anything ...
scripta's user avatar
  • 501
2 votes
2 answers
75 views

Binary search tree with Iterators

One more BST implementation with iterators added. Did not manage to find another implementation with iterators and it is my first attempt at implementing them so thought to check on your opinion: <...
acd's user avatar
  • 107