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
0 votes
0 answers
28 views

Mocking hardware related library [closed]

I'm having my first attempt at test driven development using Google Test and Google Mock, writing my Arduino project. I wanted to create a common interface for my stepper motor drivers, something like ...
Dead1nside's user avatar
-2 votes
0 answers
35 views

132 Pattern convert C++ to C [closed]

Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there ...
Arunabh Bhattacharya's user avatar
4 votes
4 answers
2k views

Yet another shared_ptr implementation for learning purposes

C++ shared_ptr implemented as a coding practice and learning purposes. It uses std::shared_ptr interface. Basic tests are included (using single header Catch 2) Some methods are omitted to keep the ...
Tomas Tintera's user avatar
2 votes
2 answers
102 views

Defining hardware components structure

I'm writing firmware for my Arduino project, and I'm struggling with a clean, scalable hardware mapping structure. Initially, I had the following namespace: ...
Dead1nside's user avatar
3 votes
2 answers
586 views

Banking System in C++ [V2]

this is the second version of my BankingSystem in C++ for the first one go here: Banking System console app in C++ I did quite a lot of changes since the last version mainly spliting the User class ...
Guy's user avatar
  • 177
2 votes
0 answers
69 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
  • 93.9k
4 votes
4 answers
2k 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 <...
Guy's user avatar
  • 177
1 vote
0 answers
45 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
  • 93.9k
-1 votes
0 answers
16 views

In C++, is checking `this == nullptr` inside member functions an acceptable pattern? [migrated]

I have seen C++ classes that check the this pointer to make sure it is not nullptr before using a field. Here is a simplified ...
Alexis Wilke's user avatar
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
76 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
42 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
  • 93.9k
0 votes
1 answer
43 views

Temperature of a Lennard-Jones system

Are the formulas used in getTemperature() and setTemperature() correct? ...
user366312's user avatar
2 votes
1 answer
43 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
  • 93.9k
3 votes
1 answer
54 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
56 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
97 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
  • 93.9k
6 votes
1 answer
168 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
  • 93.9k
1 vote
2 answers
141 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
926 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
89 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
44 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
102 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
163 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
46 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
  • 375
4 votes
2 answers
176 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
34 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
510 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
43 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
75 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
48 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
234 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
93 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
35 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
  • 93.9k
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
331 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
97 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
442 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
76 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
70 views

Windows Kernel `vector` class

...
anoncr's user avatar
  • 21
1 vote
0 answers
55 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,918
1 vote
1 answer
57 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
  • 500
2 votes
1 answer
43 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
  • 70.8k
5 votes
1 answer
366 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
  • 375
3 votes
1 answer
66 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
2 3 4 5
188