Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
1answer
25 views

PONG XI Platinum Edition

This is my first game. This header defines the constants: Constants.h: ...
0
votes
0answers
16 views

Implemeting multidimensional stencil in Cuda C/C++

I've constructed a system that contains multiple 2D lattice and a 1D cable all in a single vector of type double. Each 2D lattice is coupled to a site along the cable. For instance, there are 800 ...
1
vote
0answers
16 views

An attempt of replacing CRITICAL_SECTION with std::mutex and std::lock_guard

I have an older class that I am working on and I'm updating it to remove "Windows" specific code. It had some "Thread Protection Code" that used CRITICAL_SECTION. I'...
1
vote
0answers
31 views

Value-To-Type Map

Context For one of my projects I have to use a library which works similarly to the following code : ...
0
votes
0answers
49 views

C++ console progress display

I just figured out how to do a building menu with a progression feature in c++ console application. What this code does: It simply offers you a choice to build a building and then prints the ...
0
votes
0answers
44 views

C++ Pair Data structure

I'm wondering if this is a kind of useful way to go about implementing a well performing and generally simple pair type or is it just plain stupid? By 'simple', I mean in the sense that it's just ...
0
votes
0answers
19 views

Create a simple job system using a mutex-locked task queue

Although an experienced gameplay programmer, I'm relatively new to multithreading. I've attempted an implementation of a job system that my WIP 2D engine uses: it provides "engine" and "game" workers, ...
1
vote
2answers
66 views

Inserting an object pointer to a two-level map

I'm working on requirement that involves creating a N x N table of blocks, with each block having a weight. Consider the following classes Block - The fundamental ...
4
votes
0answers
73 views

Classic Snake Game on console

I implemented a console version of the classic snake game. I wanted it to be portable but some of the functions like setting console position and _kbhit weren't ...
6
votes
0answers
31 views

C++17 is_integral trait implementation

This is a C++17 is_integral trait implementation. Most implementations exhaust all integral types: bool ...
2
votes
0answers
7 views
2
votes
0answers
27 views

A portable cross platform C++17 method to retrieve the current date and time

I am working on a utility function to get the current date and time. My objective is to do this in a generic and portable way. I would like to stay way from platform specific code to allow the ...
3
votes
0answers
57 views

Rock-Paper-Scissors engine

Looking over Rock, Paper, Scissors. C++ from a beginning programmer prompted me to think about how I'd program this simple game in C++. The RockPaperScissors class ...
3
votes
1answer
50 views

Adaptive Merge Sort in C++

As the title says, I'm trying to implement a merge sort algorithm in C++ that's also adaptive. This is a personal exercise, and I don't have any specific application in mind. My main goal is to ...
4
votes
1answer
50 views

Reader Writer SpinLock

I'm quite new to C++ and want to focus on writing performant multithreaded code because I will try to port our company internal GUI framework which is currently implemented in C#. So I'd love to get ...
1
vote
1answer
28 views

Tagging the directories and switching between them by tags - follow-up (Part 1/2: File management)

This is a rework of a small program for faster(?) switching working directories, and it looks like a pile of crap, I must admit. Could you give me pointers how to make it maintainable? dt_tag_entry....
7
votes
2answers
117 views

Multi-threaded Conway's Game of Life in C++

Here is my implementation of Conway's Game of Life in C++ which takes advantage of multi-threading. I'm using SFML 2.5.1 for a graphics library and CMake. I also use SFML's ...
0
votes
0answers
29 views

C++ Vignere Cipher [on hold]

I'd appreciate any constructive criticism. On a side note, I can't get the ascii characters to not mix up with symbols from 91-96. ...
3
votes
2answers
89 views

Rock, Paper, Scissors. C++

I'm a beginner in programming and I would like to have feedback and tips to improve. He's a simple command line program. It's a Rock, Paper, Scissors game. I guess I could use an enum for the "Attack"...
5
votes
3answers
83 views

Functions to count vowels and consonants in strings

I am coming to a problem where I am writing a function that accepts a pointer to a C-string as its argument. The function should count the number of vowels appearing in the string and return that ...
-5
votes
0answers
30 views

Copied Source Code [on hold]

I have found this Code of a chess AI and in this part I get the Error that "\move.h|27|error: 'ssize_t' does not name a type|". And I have no idea why. It confuses me since the code was published as ...
0
votes
0answers
25 views

Auto-registering CRTP Factory

I'm trying to write a policy based auto-registering class using the Curiously Recurring Template Pattern. I decided as design choice to not using registering macro. Factory Class ...
2
votes
1answer
41 views

Concatenating an already existing filename to create a new file

I had answered this question from stackoverlow and the code below is code that I wrote to explain to the OP a possible way to achieve what I believe they were looking for. The general idea that I ...
-1
votes
1answer
46 views

C++ API design - Should I pass enums as method parameters

I have two methods which are GetMinimumSize() and GetMaximumSize(). They return the maximum size of the window, and they take ...
10
votes
3answers
3k views

Karatsuba multiplication

My implementation of Karatsuba multiplication from Tim Roughgarden's Algorithms course. I've made a Integer class that holds an integer in string format. I've added operations to this class to add, ...
0
votes
1answer
31 views

Using switch case fallthrough to clear “lower” bits in flags [on hold]

In a project I'm working on, we have a std::bitset<64> that encodes a bunch of different features about the platform we're running on. Some of those bits ...
3
votes
1answer
60 views

Isometric game engine using Allegro

I'm a self-taught programmer and I'm in the process of developing a simple 2D Isometric game. There is next to no game content yet and I've been focusing on creating solid "foundation" first if you ...
4
votes
3answers
300 views

LRU implementation in C++ using a LinkedList

Explanation : I am adding new elements in the list until the window runs out. Head will have the earliest element and tail will have the most recent element. Once the window is over, every addition ...
1
vote
1answer
104 views

Calculating array size in C++

This code shows two ways to calculate size of array of any type. I would like to know, which should be preferred? Is there any advantage/disadvantage? ...
3
votes
0answers
62 views

get; set; in C++

I wrote a class that replaces the get and set functions: ...
3
votes
2answers
109 views

Determine whether a vector intersects the up or down unit vector

I wrote an if statement that checks if an iteratively altered vector "crosses" the up vector (0,1,0) or the down vector (0,-1,0). ...
-1
votes
0answers
48 views

Recursive Dynamic programming with 3D arrays consuming time

I am trying to solve a question given on Codeforces involving dynamic programming with 3D arrays. F. Trucks and Cities There are \$n\$ cities along the road, which can be represented as a ...
0
votes
0answers
49 views

Function to check if received message matches any of the expected messages [closed]

I have a message coming in and I need to match it against the expected messages. The program will eventually do something as a result of receiving those messages. I am not very experienced at ...
3
votes
3answers
115 views

Image filter for gradient detection

This filter is basically gradient detection (the variable gradImg) like an edge detection (Sobel or Prewitt filters) and also the direction of that gradient whether ...
1
vote
1answer
51 views

Simple DP problem solved in compile time

The problem is taken from one of recent SO questions: Finding max sum of matrix elements with following constraints: Exactly one row element has to be included in the sum If element at (i, j) is ...
6
votes
3answers
101 views

C++14 std::array implementation

I invested an hour or so to reimplement the C++ header <array>. Most stuff is in the namespace my_std, but ...
1
vote
2answers
42 views

Mutex Protected Object (scoped object wrapper)

This is a class that holds mutex and associated object. On checkout/access the mutex is locked while the stack object lives and a reference to object is obtained. Any suggestions or improvements is ...
1
vote
1answer
36 views

Moving character in given direction C++ SFML

I have written simple input manager which is used for me to detect key press, and fire assigned function. For example I can do something like that: ...
3
votes
1answer
54 views

C++ OpenGL - GLFW Window Abstraction

I made a GLFW window abstraction, as I find it very useful for me to make such abstractions while learning an API, and It actually pretty much eases my work while coding. Anyways, share your ...
2
votes
1answer
53 views

Simple Mastermind in c++

i created this console application ( it's actually a Mastermind) and i would like to know what can i improve as a beginner. Thanks ! ...
5
votes
3answers
107 views

Student grade calculator using classes/ structs in C++

I am trying to teach myself C++ and using Problem Solving in C++ by Walter Savitch. This is a program project from the book that I used to practice using classes/ structs and would like some feedback, ...
2
votes
1answer
66 views

Simple Console Snake game C++

I recently started learning C++ and have made a very simple Console-based Snake Game, I would like to have some feedback on improvements. You might notice the obvious delay in clearing and printing ...
2
votes
1answer
79 views

C++ ASCII To Base64 String Encoding

My Base64 encoder class converts a string with ascii characters to a base64 encoded string with padding if required. Note that I'm not using istream as the input ...
2
votes
1answer
31 views

Using boost::mpi to take the Euclidean norm of a vector

I am learning MPI (via boost::mpi) and wrote this program that takes the euclidean norm of a 1-D vector (represented as an array here.) I want to make sure that I ...
0
votes
0answers
72 views

Algebraic data types in C++ [closed]

After some exposure to Haskell I came to love ADTs to describe 'is one of' and tree-like structures. But now that I work with C++ a lot more I want to use them in C++ too. As far as I know I have two ...
2
votes
0answers
56 views

Command line sliding tile puzzle in C++

I have rolled a simple program for controlling a sliding tile puzzle via command line. I would like to hear comments on how to make it more idiomatic C++17 and efficient. Here is my code: ...
3
votes
0answers
37 views

Calculate huge Fibonacci Numbers in C++ using GMP and boost::multiprecision

Problem Statement Calculate the exact value of the n-th Fibonacci number, say the one-billionth. Algorithm The algorithm is based on the idea that Fibonacci numbers can be represented as 2x2 ...
0
votes
0answers
86 views

Voxel Engine with Vulkan

Here is my voxel engine. I want some review for performance on the renderer. What can be improved? What must change? Also I'm not sure it is efficient to use vkWaitQueueIdle for syncing. The end goal ...
6
votes
2answers
69 views

Rearrage sequence so that adjacent numbers add to perfect squares

Consider the array: original_array1[17] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17} I want to sort it in such a way that: Sum of adjacent numbers should be a ...
3
votes
1answer
87 views

Basic substring algorithms + auxiliary string-generating functions

Summary: a bunch of algorithms to find if particular substring exists in the string. Meanwhile there's a lot to learn and I am looking forward to implementing more complex ones, I suppose there's some ...