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
1 answer
48 views

Implementing an Object type in C++

I'm currently working through the "Crafting Interpreters" book by Robert Nystrom. He uses Java to implement the visitor pattern in which the visitor functions return the Object type. C++ ...
GoZaddy's user avatar
  • 21
4 votes
2 answers
418 views

Spatial radius search in Boid simulation

I am working on a Boid simulation with 10,000 boids. I've successfully utilized geometry shaders and an array<GLfloat[3], MAX_BOIDS> for vertices to enhance ...
nowox's user avatar
  • 1,015
6 votes
2 answers
2k views

Gaussian elimination algorithm in C++

Given: j-g-h-i=0 a+b-c-j=0 c+i-d-e=0 e+g-f=0 And known: a=10 b=7 d=3 e=2 f=3 j=14 I want to solve this (or similar equations) ...
Tobias Grothe's user avatar
2 votes
1 answer
63 views

Casino Number Guessing Game

I have created a casino number guessing game in C++: ...
kit.kat.code's user avatar
1 vote
1 answer
59 views

Lazy/deferred OOP-based networking using the Epic EOS SDK

For gaming applications, networking looks strange from the point of view of traditional approaches. Much of the game logic is based on "ticks"; Most often this is a mandatory item of ...
Alexovsky's user avatar
3 votes
2 answers
83 views

Terminal Based Game [v2]

this is the second version of the Terminal Based Game I'm working on thanks to @user673679 for the suggestions, I did not implemented everything you said but it was really fun working on your ...
Ellie's user avatar
  • 347
3 votes
1 answer
83 views

C++ implementation of a concurrent queue and of a thread pool

I am working on an implementation of a concurrent_queue<T> and pf a ThreadPool, see beneath. The objectives are CPU ...
EricFlorentNoube's user avatar
0 votes
0 answers
23 views

OpenGL glut texture is faint when using the texture as a "screen" instead of the actual screen [closed]

Sorry for the confusing title, wasn't really sure how to format it. I had an idea for optimizing my horrible program, by converting the screen to a texture, and updating the texture when the computer ...
iogamesplayer's user avatar
-2 votes
0 answers
43 views

Race condition potentially because of a shared pointer, unique_ptr and PIMPL and polymorphical deep copy of class having unique_ptr data member [closed]

I am toying with the c++ code of Antoine Savine's github repository. There you have (templated) base classes Model, Product and <...
11house's user avatar
2 votes
1 answer
45 views

ReadDirectoryChangesW Improvements

I'm currently using the ReadDirectoryChangesW Function from the Windows API to build a Directory Watcher. The Watcher should monitor a folder for newly added files. ...
Kevin's user avatar
  • 145
2 votes
1 answer
75 views

How to interface a "pull" library with a "push" library using callbacks

I am using a driver that retrieves data from HW (Driver) and a display (Viewer) that will output data to the user. The user calls a trigger function to initiate the getting of data from the Driver. ...
Orange J's user avatar
3 votes
1 answer
101 views

Terminal based game - walking and collecting points

I create a game in the terminal the premise(for now) is walking around a field collecting points marked as $, and avoiding mines marked as !, the player is marked as @ and normal terrain marked as #. ...
Ellie's user avatar
  • 347
3 votes
0 answers
67 views

Re: C++ 4X Game

This post is regarding the revamp of this post/project I did about 8 months ago. I took a lot of the advice from the suggestions provided (thank you by the way), and fixed the project up, so I'm ...
Selisine's user avatar
5 votes
3 answers
2k views

"Rock Paper Scissors" game

I have created a rock paper scissors game in C++. ...
kit.kat.code's user avatar
3 votes
1 answer
85 views

Partial specialization of class template with minimal code duplication

I have a class template that stores an std::optional<T>. A very reduced version of the class template looks like this: ...
joergbrech's user avatar
3 votes
1 answer
86 views

BF Interpreter in C++

Need to clear my brain. BF interpretor in C++. bf.h ...
Martin York's user avatar
  • 94.3k
4 votes
2 answers
335 views

Class for locking shared disk directory

I'm writing an application to sync files between two directories. In order to prevent simultaneous access to the shared directory from several computers, I implemented blocking of the shared directory....
Andrey Epifantsev's user avatar
2 votes
0 answers
27 views

A recursive_fold_right_all Template Function Implementation in C++

This is a follow-up question for A recursive_fold_left_all Template Function Implementation in C++. Besides recursive_fold_left_all function, I am trying to ...
JimmyHu's user avatar
  • 3,974
4 votes
2 answers
118 views

C++ heap allocator using an explicit free list

Description I've written a heap allocator in C++ using an explicit free list for organization. I've also written a series of unit tests and a microbenchmark using Catch2. At time of writing I've ...
pdm's user avatar
  • 307
3 votes
1 answer
62 views

Multi producer/consumer lock-free queue

I would be grateful if you could review my code for a multi producer/consumer lock-free queue in C++. I am mainly after performance improvements, but all input is welcome. ...
Mr. Orange's user avatar
1 vote
2 answers
1k views

Calling fgets() twice

I am a beginner. I have really struggled with fgets() when using the function twice. I am on Windows with VS Code and C++ extension. My test program is working, but it is IMHO lengthy and complicated ...
mortenlund's user avatar
2 votes
1 answer
89 views

Codeforces: Dasha & Nightmares

so I got started with competitive programming about a day ago and I got stuck on the first random question I tried on codeforces. It's called Dasha and Nightmares. Problem Description: The problem ...
st0n3r's user avatar
  • 73
2 votes
1 answer
274 views

Printing the elements of a forward linked list

I'm a sophomore in computer science who's working on a linked list class for his DSA class. I believe this code can be improved, but I'm not sure how because everything got really messy really fast. ...
o_22's user avatar
  • 23
1 vote
1 answer
49 views

Template for making distinct numeric type aliases

I've tried to make a small template for the creation of distinct (incompatible) numerical types. For example both row and column indices are usually represented as the same underlying type. However it ...
Sam Coutteau's user avatar
10 votes
3 answers
2k views

Cumulative grade-point-average calculator in C++

I wrote a simple Cumulative grade-point-average calculator in C++, and would like to ask for advices to improve the code in terms of best practices (efficiency, reliability) in the language. Here's my ...
kit.kat.code's user avatar
-2 votes
1 answer
65 views

Double set to -1 from function does not equal to -1 in comparison [closed]

I use the function trace() to calculate the trace of a matrix. This is not important. But for this specific matrix this value is -1. My variable "trace" is set to this from the function. ...
Lorde213423432e43434's user avatar
1 vote
0 answers
53 views

Basic base for Phys engine. with SFML and ImGui

I want to create very basic physics engine in SFML. And i also want to be able to control objects using ImGui. So i created this basic foundation. My main problem with it is how i handle rendering gui,...
pyt4's user avatar
  • 11
2 votes
1 answer
116 views

OrderBook Implementation - Follow up

This is a follow up to my previous implementation: The input is of the format ...
Avengerx9's user avatar
2 votes
1 answer
48 views

Shared_ptr Implementation with Derived class Awareness

Another shared_ptr implementation. My main idea was to write it in a way you could do: ...
KimGiacinto's user avatar
2 votes
2 answers
159 views

Design decisions for an efficient OrderBook

I am designing code for OrderBook based in C++, based on STL library. Note that there is a related question here, however it is more simple - it does not support deletion of orders, and I intend to ...
Avengerx9's user avatar
3 votes
2 answers
159 views

String partial implementation using a vector

I saw few similar solutions, but they all relied on C-style arrays and str utils, so I thought I would write a higher level C++ only implementation with a vector as an exercise. I have not implemented ...
KimGiacinto's user avatar
1 vote
1 answer
73 views

An Updated recursive_reduce_string Template Function Implementation in C++

This is a follow-up question for A recursive_reduce Template Function with Unwrap Level Implementation in C++ and A recursive_reduce_string Template Function Implementation in C++. Considering the ...
JimmyHu's user avatar
  • 3,974
9 votes
3 answers
3k views

Recreating Minesweeper

First, I have to say that this game lacks 5 features that I don't care: Flags Chording Timer Actual mouse movement Good graphics When starting the program, the player is meeted with a "Choose ...
Le_Square's user avatar
1 vote
1 answer
99 views

A recursive_reduce_string Template Function Implementation in C++

This is a follow-up question for A recursive_sum Template Function Implementation with Unwrap Level in C++, A recursive_reduce_all Template Function Implementation ...
JimmyHu's user avatar
  • 3,974
2 votes
1 answer
102 views

Tic-tac-toe game for Windows console

I am doing C++ for over a year and this is my game I tried making tic-tac-toe. And it's also my first program that uses multiple source files. main.cpp ...
NikolaTeslaPaga's user avatar
2 votes
1 answer
133 views

Alarm - Timer - Stopwatch with <chrono>

Alarm, timer and stopwatch in the style of the standard library. Important design notes: The accessors do not update internal state, the user is responsible to call ...
demiralp's user avatar
  • 123
2 votes
1 answer
668 views

Little CLI game in C++ with random words

the game is quite simple, you have to constantly guess the letters of a hidden word, but has a limited number of wrong attempts. The word you are looking for should be a random word from Wikipedia. I ...
Tobias Grothe's user avatar
3 votes
1 answer
102 views

IMAP client impementation on State Machine boost-ext/sml

I made IMAP(IMAPS) notifier on boost-ext/sml state machine. There is an opinion that networking is best done on machines. Compile in C++20. Tested on GMail server. Uses karastojko/mailio (and ...
Alexovsky's user avatar
3 votes
1 answer
119 views

C++ two-phase path-compression quick-union union find over indices

This is my first C++ class, implementing union find. I’ve tested the implementation very shoddily by checking that unifying two points connects them, and that works. I did a first draft in Python and ...
schuelermine's user avatar
2 votes
2 answers
146 views

Improved input validation function

A week ago I posted this question and after reading the answers and accepting one I decided to refactor my code quite heavily. I would like to get some feedback on this newer version. The changes No ...
globalturist's user avatar
2 votes
1 answer
244 views

Traveling Salesman Problem for visiting cities

Implement TSP problem using best first algorithm (so it will be backtracking, branch-and-bound, and best-first). Since you are looking for a cycle, the start/finish city is not important. Therefore we ...
Ruiru's user avatar
  • 21
3 votes
0 answers
86 views

Modern OpenGL Context that doesn't rely on CRT

I'm working on a personal OpenGL project. I want my project to not rely on any libraries including CRT. I have absolutely no experience in shipping software and I want to prepare my code for release. ...
Cherestes Radu's user avatar
3 votes
1 answer
245 views

Single threaded epoll based coroutine library for C++, Linux

I've implemented a small single-header library over the C++20 coroutines. This library only works on a single thread and it is limited to Linux because it is also based on epoll. The library does not ...
Pangi's user avatar
  • 145
3 votes
2 answers
165 views

Multithreaded disk scan

I'm writing an application to compare and sync folders on a disks. Scanning the contents of folders is performed in separate threads. I wrote a class to manage scan threads. The main application class ...
Andrey Epifantsev's user avatar
0 votes
1 answer
51 views

C interface exception handling with C++ implementation

Whilst developing a bigger project, I was in need of having basic error handling inside the context of a C interface. I came up with the following solution. ...
Sam Coutteau's user avatar
2 votes
3 answers
164 views

Making an input validator function

NOTICE: I refactored the code and made a new question like was advised. I'm making an input validator function that is inspired by @JDługosz from the following post so that other new C++ programmers ...
globalturist'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
114 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
644 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 ...
Ellie's user avatar
  • 347
2 votes
0 answers
77 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

1
2 3 4 5
188