2022 Developer Survey is open! Take survey.

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
2 answers
36 views

A probability distribution function, to be called repeatedly during numerical integration

I am trying to speed up as much a possible this function in C++. As I explained in another post, Implementing multidimensional integral for a custom function in C++, this function will be used inside ...
user avatar
-3 votes
0 answers
26 views

Bank-system-managmennt improvement and refactor [closed]

I need a some comment my code and give me idea how to improve that, maybe use database to that or sth. Because I have no idea what can I do that - to improve this ... :/ I need motivation :/ I believe ...
user avatar
1 vote
2 answers
64 views

Minesweeper implementation in C++

I have implemented minesweeper in C++. You can get a box by entering the coordinates -row number, then column; starting from 0- of said box (eg: "0 0"); you can mark a box as a bomb by ...
user avatar
6 votes
2 answers
346 views

std::array based push-only circular buffer

Minimal implementation of a circular buffer based on std::array, where elements can only be pushed and iterated. I'm interested on potential failures and very trivial optimizations, as I'd like to ...
user avatar
  • 161
1 vote
1 answer
43 views

Binary Search Tree implementation in C++ with templates

Im implementing a BST using templates and dynamic memory, here is my attempt: This is the BSTNode.hh ...
user avatar
  • 269
1 vote
1 answer
31 views

Asking for C++ advice based on a radix sort function

Can someone point out what possible edge cases/leaks/inefficiencies my code has and how they could be avoided/fixed. Basically, I want to know what mistakes I make so I can avoid making them in the ...
user avatar
2 votes
2 answers
36 views

Simple non balancing indexed binary search tree

The following code represents a simple indexed binary search tree of integers. The insert method inserts an int. The indexed lookup looks up the ith smallest element (0 indexed). I'm trying to write C+...
user avatar
  • 21
1 vote
1 answer
38 views

Adapter pattern in C++ via Inheritance and Composition

Any suggestions on how the implementation of the C++ Adapter pattern could be improved here? Implemented via: Composition Inheritance What needed to be adapted was the ...
user avatar
2 votes
2 answers
125 views

Implementing multidimensional integral for a custom function in C++

I am not an expert with C++, but I am trying to implement a 4-dimensional integral using GSL numerical integration approach. The code below shows the whole algorithm. Although it seems correct what I ...
user avatar
4 votes
1 answer
95 views

Blackjack game in C++

I developed a blackjack game. I am relatively new to c++ and OOP, so I am asking for feedback on what could be improved. This game features betting, taking a card, standing, and splitting a hand. ...
user avatar
2 votes
1 answer
60 views

C++17 view over the Ith elements of tuples in containers of tuples

For mainly didactic reasons, I have designed my ElementsView<I, T> class template, which provides a view over the I th ...
user avatar
0 votes
1 answer
30 views

How do I increase the memory efficiency of this longest substring implementation? (C++)

I'm practicing my coding on leetcode. I implemented the following algorithm to solve the longest substring problem: ...
user avatar
2 votes
1 answer
55 views

C++20 Multi-queue Thread Pool with Work Stealing

This is a follow up to my previous post which also follows up on my first post regarding my thread pool implementation. I have since made some further changes and attempted to improve performance with ...
user avatar
4 votes
1 answer
170 views

Create and view a family tree

I have an assignment due Friday to make a family tree. Started to code in January. My reviews from the teacher for this code was that the use of pointers was horrendous and it wasn't OOP enough. This ...
user avatar
  • 43
0 votes
1 answer
51 views

Excessive space C++ string [closed]

Extra gaps A string is given. Write an application that will remove all extra spaces from this string. A space will be considered superfluous if: it is at the beginning of the line, before the first ...
user avatar
  • 1
0 votes
0 answers
9 views

Insertion of node at tail in linked list [closed]

In this why are we using return statement in if condition of function void tail() also why when we use node* head as argument in void tail() istead of node* &head gives us NULL ?? ...
user avatar
1 vote
1 answer
63 views

"Fast Pimpl": aligned storage instead of the pointer, special member functions

I have attempted to implement a "fast Pimpl" idiom based on the talk slides and further sources, which is essentially an aligned storage of some size that can be used as a drop-in ...
user avatar
  • 113
2 votes
1 answer
58 views

Map: Group Tuple keys Together with Empty Elements

Introduction We have std::map<key,std::vector<std::string>> m; where the key is represented by ...
user avatar
  • 191
1 vote
1 answer
42 views

Number of paths in a randomly labeled complete graph

I have a complete graph with n vertices, set W (let's say W = {1,2,3}) and a path ...
user avatar
  • 13
1 vote
1 answer
56 views

Passwords with C++ Console

I am really, really new to coding in general and especially c++. To get more familiar with c++ I am trying to do a series of projects with c++ console apps. One of my projects is with a database that ...
user avatar
2 votes
1 answer
120 views

Sum two vectors in x86 assembly

I recently made a program with C++ and ASM. Can anyone help me make this code a more efficient one, in the ASM part or both. I would really appreciate it because I don't know every ASM instruction and ...
user avatar
2 votes
1 answer
54 views

Chess game setup: Initial board state

This app only creates a chess board set to the start-of-game state. It does nothing else. I'd appreciate feedback on the files that are relevant to this board setup (all shown below: board.cpp, pieces....
user avatar
1 vote
1 answer
55 views

Linked list implementation in cpp

I need some review for this CPP Linked list implementation. This is my first time implementing such a data structure in CPP. Thanks in advance. ...
user avatar
4 votes
2 answers
78 views

Multi-threaded Mandelbrot set generator slower than single thread

I am new to parallel programming. I have been playing around with multi-threading and for some reason, multi-threading the Mandelbrot set is slower than running a single thread. I have been trying to ...
user avatar
0 votes
0 answers
24 views

Event callbacks library

This is a small library I wrote to make event callbacks with variadic templates work like C#'s event system (placeholder template by "dyp" at http://stackoverflow.com/a/21664270). Just like ...
user avatar
1 vote
2 answers
59 views

Requests and handling requests

For this task, I don't think that the Observer Pattern can be used in its classic form. Those who have received the requests and those who choose to accept the request are not the same group. Those ...
user avatar
  • 1,089
1 vote
1 answer
60 views

Using std::variant with std::ranges algorithms

I have some predicate objects that take some value and return the result of some criteria. (My real implementation is more complex, this is only a minimal example): Run on Compiler Explorer ...
user avatar
  • 125
-2 votes
1 answer
68 views

Could someone tell me how good/bad this code is and why, thanks [closed]

I am doing a coding exercise on leetcode, but wondering, is this a good coding? Please help check https://leetcode.com/problems/text-justification/discuss/2017233 Here is the code copy: ...
user avatar
0 votes
1 answer
24 views

Modify a string by identifying a substring, and replace it and the characters following it with a newly computed substring

I'm working on a string manipulation code in C++ for my internship project, where I have to find a substring within a string and essentially replace it and some characters following it with a newly ...
user avatar
2 votes
1 answer
57 views

Reading a list of names, counting them and ordering them

I would like to know does this code follow common best practices in C++ using STL. Goal of the code: There are 10 players that were playing a game 1000 times. Each time someone has won they have put ...
user avatar
3 votes
1 answer
53 views

Topological Sort C++

Comments on optimizing the code or improving the code are requested. The input parameters to the class constructor are a one dimensional array of job ID's and the second argument is a list of vectors ...
user avatar
1 vote
1 answer
92 views

Storing different types with common base using atomic-based typeid

I'm trying to develop some kind of in-memory store for my entities. These entities are representations of the devices available on the system. There may be eg. 3 leds, 1 temp sensor, 2 engines etc. ...
user avatar
  • 241
5 votes
1 answer
85 views

С++: Find max element from section in matrix

I'm a newbie in programming. Could you please check my code and give any refactoring ideas, tips, etc... how it can be improved. I wrote a code to perform the following task: Find in randomly filled ...
user avatar
2 votes
1 answer
71 views

Program to check if a window is opened or not during some time interval

I'm trying to write a program that will check if a window is opened or not, during a given time. I was able to do that, but now I'm trying to make my code look cleaner. I don't like how I implement ...
user avatar
1 vote
1 answer
31 views

Sort and search vectors by different criteria

Class class Player { std::string name; int score; int id; }; I thought about how to write a code to sort and search vector ...
user avatar
  • 11
2 votes
1 answer
41 views

UPDATE #1: Lengthening the time it takes to access files using function hooking

https://github.com/speedrun-program/load_extender This is the previous post: Lengthening the time it takes to access files using function hooking I tried adding everything from the previous post's ...
user avatar
1 vote
2 answers
63 views

Reading 12-bit words from 32-bit stream

I have a device (ADC) that stores its samples in a 32-bit buffer and each sample is a 12-bit word : I needed an algorithm to read those samples to a container (say ...
user avatar
  • 771
0 votes
0 answers
42 views

Component to apply FABRIK in Unreal Engine

I read the FABRIK and implemented it to study Unreal syntax. Update the position in the FABRIK Segment component. It is used to update the relative position of the static mesh using the updated ...
user avatar
1 vote
0 answers
55 views

Snake game as console app in c++

I made a snake game as console aplication. It was my first real little project I did all alone. I tried using best practices I learned but I've got lost few times so I suppose there will be some bad ...
user avatar
  • 11
3 votes
0 answers
52 views

Accelerating this stacked matrix-matrix product in OpenCL

I am trying to compute a matrix-matrix product of N stacked complex double N x N matrices. For simplicity, I assume N = 512. I have written code in C++ parallelized with OMP and using OpenBLAS for the ...
user avatar
  • 31
8 votes
2 answers
598 views

Markup Language Parser in C++

I'm new to C++ and decided to write a parser for a markup language. I chose org-mode because it seemed relatively straightforward. parsertest.cpp ...
user avatar
2 votes
1 answer
55 views

UpdateCustomer - implementation in C++

I am trying to write a program that does the following: The application will read the customer and book orders data from a data file “BookOrders.txt” and load them in a customer linked list, each ...
user avatar
2 votes
1 answer
53 views

Lengthening the time it takes to access files using function hooking

https://github.com/speedrun-program/load_extender This is something I made and posted here about a year ago, but I decided to remake it. To compile this on Windows, you need to install EasyHook. ...
user avatar
0 votes
0 answers
8 views

Is this a safe / correct implementation of a variadic list argument used to simplify setting "pinMode"? [migrated]

Code (C++): I'm new to C++ so I'm not sure if this is safe: ...
user avatar
1 vote
2 answers
43 views

C++ variardic universal template for unknown types, used to handle multiple network protocols

I am creating a template function with variardic arguments, to handle a specific classes that have some interface, method, member or whatever is specialized in a specialization area. However I came to ...
user avatar
1 vote
1 answer
51 views

Infix calculator programming challenge Kattis.com

I'm working on this C++ coding problem: Input is a sequence of up to commands, one per line, ending at end of file. Each command is a definition, a calculation, or a clear. All tokens within a ...
user avatar
1 vote
1 answer
84 views

ASCII game in console [closed]

Overall, I want to make a game in console, something Pokemon-like but with typical rpg scenery - swords, magic and all that. I want to make player able to move around the map, find dungeons, fight ...
user avatar
1 vote
1 answer
68 views

Connect Four in C++

This is a library that implements the logic of Connect Four. There's nothing related to graphics or user input here. This library is supposed to be integrated into any environment where one could run ...
user avatar
  • 993
0 votes
2 answers
49 views

C++ shared_ptr<vector> mechanism

I'm so unsure that I am deallocating memory right. I am probably unable to figure out is shared_ptr destroyed or not, it seems to be impossible according to if checks, so maybe I need some try catch. ...
user avatar
  • 3
0 votes
1 answer
21 views

C++20 Wrapper class for an unsigned integer type and a templated derived class that codes modular arithmetic type

The context is a library to represent numbers (in this case integers) by wheighted position by radix powers for every radix R, passed as template argument. These derived types are digits of radix R, ...
user avatar

1
2 3 4 5
179