C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.

learn more… | top users | synonyms (1)

0
votes
0answers
2 views

Terminal ESC Sequence Decoder

Figured i'd share some code and get some feedback. The goal of this code is to read-in a stream of terminal ESC sequecnes, and break them down and fill a vector of parameterized sequences for ...
0
votes
0answers
26 views

Generating the largest decent number of given number of digits

This programming-challenge from HackerRank says to generate the following number with \$n\$ number of digits and \$T\$ test cases: A Decent Number has the following properties: its digits can only ...
0
votes
2answers
36 views

Variadic average function in C++

The following code was inspired from a tutorial I found online: ...
3
votes
1answer
31 views

Generate voxel terrain with Perlin Noise

For my chunk generator for my game, it currently uses a triple nested loop, which seems very inefficient. It also seems like I could cut down a lot of code in the function somehow. Does anyone have ...
0
votes
0answers
14 views

I'm trying to make a good naming for class family [on hold]

I want to extend idiom of NonCopyable class for cases where object cannot be copied or moved via copy/move constructor or assignment operators. So i divide idiom ...
4
votes
2answers
28 views

Vector Sort Function

I had heard about sorting for a while, but never actually gave it a try. So I decided to make an algorithm that would sort the members of a vector from least to greatest. Though this may seem pretty ...
1
vote
0answers
33 views

Generic implementation of mutable binary heap

std::priority_queue does not support dynamically updating element priorities. This class template extends it by allowing updating priorities of elements in the ...
1
vote
1answer
48 views

Attempt at Conway's Game of life

I tried my hands of Conway's Game of life. Well it works as I wanted it to but I want to improve my design and coding practice. I will be glad to get feedback and ideas to improve it and how to code ...
2
votes
0answers
25 views

Parallelizing an algorithm with OpenMP using a dynamic work queue

I'm looking for comments on the design, correctness and performance (not so much style) of a dynamic work queue for OpenMP worker threads. I have an algorithm that can be thought of in terms of some ...
6
votes
4answers
859 views

Random string generator

I decided to make a random string generator for fun, and it works for the most part. Since I'm an amateur at programming, I thought I would post the code to get some feedback on it, and hopefully ...
1
vote
1answer
61 views

Printing all the prime numbers between two bounds

I keep getting a time limit exceeded for this solution to SPOJ Prime1. I need to print all primes within a given interval (with intervals as large as 105, and numbers as large as 109). I've tried ...
-3
votes
0answers
53 views

C++ Interfaces and Design Principles [on hold]

How does a SOLID compliant interface in C++ could be implemented? For example, is this design below SOLID compliant? I have several questions: In the Car ...
1
vote
1answer
36 views

Generic implementation of SiftUp/Down operations on binary heap

Binary heap construction and maintenance boil down to the two basic operations: sift up and sift down. Following are generic template implementations of the two operations. Any comments are welcome. ...
1
vote
0answers
67 views

HackerRank: XOR-sequence

I am trying to solve the following problem at HackerRank: XOR-Sequence An array, \$A\$, is defined as follows: \$A_0 = 0\$ \$A_x = A_{x-1} \oplus x\$ for \$x>0\$, where ...
3
votes
0answers
49 views

Game engine/C++11 software 3D renderer/WebGL library

I am a graphics programmer and was wondering about my code quality. I selected these three examples: Game engine, which uses OpenGL and has a lot of other non-graphics code A 3D software renderer, ...
1
vote
1answer
50 views

Grabs 10 bytes and converts it into a hex formatted string

I'm working on some code right now where the goal is to take in a byte stream and grab the data from the body of a message. The data is 10 bytes long and is meant to be translated into hex. ...
3
votes
0answers
26 views

LifeSaver: Hides and manipulates windows

This is my first post. I think I'm an Intermediate. This is a small program I wrote to hide/show different windows on my Windows PC. This is named LifeSaver ...
0
votes
1answer
31 views

Substring erase with certain pattern

For following input string: ...
1
vote
2answers
38 views

Sorting an object array

I've created a class called Box that is pretty much what it sounds like. I want to sort these box objects, and I have created a function to do so. ...
-1
votes
0answers
20 views

Sort strings using selection sort without changing original values [on hold]

I've created a function that sorts strings using selection sort, but I want to know if I can do this without changing the original strings. For example, if I try to sort an array ...
2
votes
0answers
42 views

Dynamic graph in C++11 with shortest path algorithm

I've been designing a dynamic graph to improve my understanding of C++11. The dynamic aspect means that it could represent the hyperlink structure of a chunk of the internet, with node deletion ...
0
votes
1answer
34 views

Couting numbers greater than given - using binary search

It's my first exercise involving the well-known binary search. The problem goes as follows: we are given a sequence of n numbers and we have to answer to t questions, each of which is: “How many ...
6
votes
0answers
98 views

C++14 Event System

I've created a simplified event system for C++14. The code is commented, so it shouldn't be hard to read. There's also a simple usage scenario below. It is still a work in progress and uses some ...
5
votes
1answer
88 views

A* implementation

I wrote a little A* implementation by my own and would like to have some feedback ;) The code is in OOP way, thus we can use an other pathfinding algorithm easily. The "Base" is just the interface ...
5
votes
4answers
99 views

Risk battle simulator v2

I wrote a Risk battle simulator that returned the odds of every possible outcome and put it up to be reviewed here. I used the comments to improve it, and am wondering if it can be optimized further. ...
5
votes
3answers
115 views

Simulation for rolling dice in X-Wing

I've recently started playing the X-Wing Miniature game, and there is quite some math behind some of the dice rolls, as they are affected by many abilities and so on. Manually calculating these is ...
9
votes
1answer
68 views

OpenGL shader class

I'm working my way through some basic OpenGL tutorials and have decided to offload the shader loading/compiling/linking to a separate object that I'll use for the remainder of the tutorial material. ...
3
votes
3answers
60 views

Bit manipulation tool set

I made a tool set to facilitate bit manipulation as follows. Any comments are welcome, be it about the interface design, the implementation, or even the naming. Also, I want to make sure that the tool ...
1
vote
1answer
22 views

getProcID and getProcessHandle functions

I made two functions: one to get process id and the other to get a handle with all access to that process using the process id. I'm looking for help with making these easy to use on all types of ...
-1
votes
0answers
19 views

Returning a pointer from a class member [closed]

I have two classes Person and Student with Person being the base class and Student being the derived class. The question states that I must within the Student() operator when a student member is ...
5
votes
1answer
104 views

NMEA 0183 checksum validation

I was hoping for a bit of advice on cleaning a couple of areas of this code up. In particular, the hex-to-binary section, the checksum is in hex, and the rest is in ASCII. I tried for a good day to do ...
0
votes
0answers
19 views

Classic snake game [closed]

I am trying to make a classic snake game using a 2 dimensional characetr array as the map. But when i run my program the snake (depicted by X in the game) does not move at all in the direction. please ...
3
votes
2answers
86 views

Slow merge sort

...
1
vote
1answer
49 views

Template for wrapping fundamental types and other basic POD structs in C++

I wrote this, which I'm not sure if it's of any use yet but at least it saves me some time when writing atomics to a file or raw memory. What I was thinking is that the conditional in the ...
3
votes
4answers
97 views

C++ Interrupted Bubble Sort

I've written an interrupted bubble sort, which prints the intermediate result after some specified number of iterations of bubble sort. But I seem to have an speed issue. Could anyone help me spot ...
4
votes
1answer
67 views

Octree for voxels

I am creating a game with destructive terrain. Before I used a flat array to store the blocks, in chunks of 32^3. As I am aiming for detail and long view distance I would of course need some sort of ...
3
votes
1answer
68 views

Implementing a Time class in c++

Design a class TIME which stores hour, minute and second. The class should have the methods to support the following: User may give the time value in 24-hour format. User may give ...
7
votes
1answer
57 views

Assembler listings parser components: Operands parser

I'm building the above mentioned parser. It reads a string of assembler instructions. I want to become a better coder, so I wanted to get a code review to start learning to do things property. As we ...
2
votes
0answers
77 views

Nested loops with linear array

i have found this article on how to loop through multi-dimensional arrays quickly. http://nadeausoftware.com/articles/2012/06/c_c_tip_how_loop_through_multi_dimensional_arrays_quickly I am using ...
3
votes
0answers
46 views

Determining if a genetic sequence is palindromic

Adding another level to my previous question on 'normal' palindrome identification, in this one I'm interested in identifying genetic palindromes. Here's my attempt: ...
4
votes
1answer
67 views

Determining if a sequence is a palindrome

To complement this Java question on palindrome identification, I came up with this C++(14) version: ...
3
votes
0answers
34 views

Multi-dimensional view of a one-dimensional object

Sometimes, we create a one-dimensional object, but want to access it in a multi-dimensional way. For example, you can access an int[8] array object in a 2x2x2 way. ...
2
votes
2answers
40 views

ShoppingCart and Item Classes

I've built a class for an e-commerce Item, and the ShoppingCart class for checkout functions. The thing I'm most concerned ...
1
vote
0answers
18 views

Type traits for ConfigLoaders

I recently added this ConfigLoader class to my project : it loads information (in this example for a window) from an XML config file, using boost. I would like to ask your advice if this is a good ...
1
vote
0answers
56 views

C++ base class for heap awareness

I have a few classes that form a class hierarchy where some objects point to others. In the usual case, I create these object on the stack. In other cases, I need to clone these object to do some ...
3
votes
1answer
56 views

Handy tool that provides easy syntax for specifying multi-dimensional types in C++

The syntax for specifying multi-dimensional types in C++ is messy. For example, to specify a two-dimensional std::vector<int>, one has to write ...
-2
votes
0answers
33 views

Solving a system with 2 linear equations with 2 unknowns

This code finds the solutions of a system of 2 linear equations. I used Kramer's rule to find the unknowns, but I wanted to do this using classes. I don't know if this is the right way to use ...
6
votes
1answer
92 views

Comparing std::vector<bool> to std::vector<char>

A recent comment to an answer of mine here on Code Review brought up an interesting point. The comment was that one should use std::vector<char> over ...
4
votes
1answer
48 views

Recursive backtracking Sudoku solver

I'm trying to learn more algorithmic techniques and I came across an interesting application of recursive backtracking: solving a Sudoku puzzle. I'm looking for a review concerning code style, ...