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

learn more… | top users | synonyms

0
votes
0answers
7 views

Parse strings and respond

I'm doing some exercises from another good website aimed at a similar problem - exercism.io, and my 1st C++ problem was to pass a certain test suite. Here is the README for relevant information: ...
1
vote
0answers
7 views

`std::vector` 'substring concatenator'

The point of this is to concatenate a vector of std::strings into one string starting at an index of the vector. ...
0
votes
0answers
28 views

Serial port write buffer

I'm writing to some serial comm port with specific bytes set into buffer. My protocol for write buffer is written below. Platform is Windows and IDE is Visual C++. Byte 0 will have message type ...
-1
votes
0answers
12 views

perform binary trees search based a collection of data [on hold]

i was asked to write a BTS code for a collection of data with have the x, y and z coordinate, which has negative and positive number, and the requirement are below: That program is capable to ...
3
votes
0answers
29 views

Statics/globals initialization order multi-platform workaround

I was looking for a solution for initializing simple global constants which depend on other globals/statics defined in different translation units. It is well known that the order is not ...
4
votes
1answer
30 views

for_each_cons and for_each_slice, variants of std::for_each working on sliding windows

My goal was to replicate Ruby's each_cons and each_slice: ...
2
votes
1answer
38 views

Generic Graph Abstract Data Type Implementation in C++

Today I tried to code up a generic graph abstract data type in C++. Precisely, I implemented the adjacency list data structure for a generic graph type. I think it seems to work with different type ...
2
votes
3answers
46 views

Searching a string of consecutive characters in a binary bar code

I am writing a program that will take a binary bar code and convert it to a zip-code. I need to validate the bar code. A valid binary bar code contains no more and no less than two 1s in any position ...
3
votes
0answers
16 views

Improving my build_max_heap algorithm [on hold]

I'm new to such complicated (for me) data structures as binary trees now. I think I've made many mistakes in my build_max_heap algorithm and it can be improved. The rule I'm using is that smaller ...
6
votes
5answers
888 views

Sort three numbers using only if-statements

Beginner here, trying to make a small program that sorts three numbers from smallest to largest only by using ifs. Any thoughts on how to improve this? ...
3
votes
2answers
44 views

Search key in a rotated sorted array without repetition of elements

Is there any improvement possible in this implementation? //Search in sorted rotated array ...
0
votes
1answer
34 views

A Polynominal class [on hold]

Here is the problem I am trying to solve: Using dynamic arrays, implement a polynomial class with polynomial addition, subtraction, and multiplication. Discussion: A variable in a polynomial ...
11
votes
3answers
178 views

FizzBuzzWoofFooBar

My C++ was starting to get rusty and I never touched some of the newer features. Reason enough to try something simple and make it overly complicated: FizzBuzz with bonus features. For now we'll call ...
7
votes
4answers
608 views

Kelvin-Fahrenheit-Celsius temperature converter

I am curious if it would ever be in good practice to omit constructor definitions from a class. Here, the intention of the Temperature class is to simply convert between one temperature scale to ...
5
votes
1answer
54 views

Thread-Safe Variadic Printing Function

Printing to stdout is thread-safe in many systems when using printf or std::cout, but not in ...
4
votes
1answer
96 views

Project Euler: Problem 22 (2 versions)

I wrote 2 versions of problem 22 on Project Euler: Using a text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value ...
8
votes
1answer
37 views

Mathematical expressions evaluator with callbacks, the architecture

This question goes hand in hand with another question about a mathematical expressions evaluator in C++. The other question is meant to be read first, this one is but a complement to expose the ...
9
votes
1answer
72 views

Mathematical expressions evaluator with callbacks, the logic

I hesitated quite a bit of time before posting this question since the code to review is more or less a monster (with regards to its size). It is a basic mathematical expressions evaluator, but with ...
-1
votes
0answers
41 views

Using m vs this. for member variables [closed]

First time posting here. I hope my question is ok. If I have a class with some member variables, some people follow the naming convention that prefixes member variables with m ...
5
votes
3answers
73 views

Adding Reversed Numbers - ADDREV on SPOJ

Today I tried solving this problem on SPOJ, in which you reverse the digits of two numbers, add them, and print the reversed digits of the sum. (When reversing, leading zeroes in the result should be ...
3
votes
3answers
77 views

Merging Digital River

I am solving this question: It's not the rivers that you might be thinking about. The question revolves around the concept of digital rivers. A digital river is a sequence of numbers where the ...
-2
votes
2answers
60 views
6
votes
0answers
47 views

A Smarter random bomber for Battleship

In a further exercise of my original Battleship test framework, I have enhanced and refactored the SmartRandom class from an earlier question and have updated ...
7
votes
1answer
91 views

Continuation Implementation in C++11

While playing with the concurrency features in C++11 I noticed that there wasn't any support for continuations. I wanted to develop something similar to Tasks in The Parallel Patterns Library (PPL), ...
1
vote
1answer
41 views

Naive demosaic for bayer images

I have this legacy code and I don't really think this is easy to read/maintain it. Can you suggest a way to make this more readable while still saving the performance? ...
2
votes
0answers
28 views

Maze player model view and controller

This is the player view model and controller for human player using a keyboard (easily extendable for over the network / split screen mode) The AI controller is posted in another post I've made ...
2
votes
0answers
22 views

AI for depth-first walking in a maze, with variable depth look ahead search for dead ends and finish point

This code is a part of a little game I've started a week ago. It is too extensive to review at once, so I'm picking the most interesting and crucial parts. Start with the AI. It has public update ...
11
votes
2answers
583 views

Console maze program

My most recent project was a console based maze game and I wanted to get some feedback on it. Is there a better way to design my code? ...
2
votes
0answers
48 views

Share data and mutexes across threads

I need a class that holds a huge amount of data, which should be useable across multiple threads. To avoid copying the data every time, I used a std::shared_ptr. To ...
1
vote
1answer
55 views

A binary tree , its copy constructor and assignment operator

I implemented a binary tree in the following code. Its node's copy constructor and assignment operator should copy itself and all its descendents. Similarity a node's destructor should delete itself ...
3
votes
1answer
54 views

Representing vehicles and their components

I am working on a project that needs to represent different kinds of vehicles, components of these vehicles and actual parts of the components. So far I have this code: ...
5
votes
3answers
1k views

C++ Pig Latin program

I'm just wanting some input on to how others would approach this problem. I am learning and wish to gain insight on others techniques. Be as critical as you need. I want to learn. I feel this code is ...
5
votes
1answer
102 views

Linear algebra module

I'm working on a linear algebra module to improve my knowledge with mathematics and, because I'll need a lightweight linear algebra module for my future work with Vulkan! I tried to keep a blas-like ...
3
votes
1answer
52 views

Making a copy constructor more flexible for ADT queue

I have constructed a copy constructor for an ADT queue. The copy constructor works fine. I would want to improve my code, but I don't really know how to shorten it to make it more flexible. ...
1
vote
2answers
80 views

Implementation of unique_ptr and make_unique for aligned memory

I am working on a version of std::unique_ptr and std::make_unique for aligned memory. The purpose of this is vectorization, ...
6
votes
2answers
144 views

Rock, Paper, Scissors Game in C++

Below you will find my first attempt at a C++ implementation of the classic game Rock, Paper, Scissors. If someone could look it over and point out or suggest any things that I could change to improve ...
6
votes
1answer
70 views

Lock-free, multiple consumer, multiple producer queue

I'm implementing a lock-free, multiple consumer, multiple producer FIFO queue/pipe as an exercise in thinking about atomicity in operations. My main concern is correctness of operation, my second ...
1
vote
1answer
38 views

boost::spreadsort for std::pair

Boost 1.58 has new library spreadsort, so I tried it out. I wrote simple sample for sorting vector of pairs of int: ...
4
votes
1answer
88 views

Lockless multi user, multi consumer FIFO queue using C++11

One of the features that is missing from C++11 are lockless queues. Therefore I have decided to write one myself. A few remarks: I know the code isn't technically lockless. However the lock is only ...
2
votes
4answers
317 views

Rule Of Three for a Coordinate class [closed]

I just recently got back into C++ and did a quick and simple exercise in the Rule of Three. The code for the copy constructor, overloaded assignment operator, and destructor follows below for my class ...
4
votes
2answers
95 views

Object-oriented Rock, Paper, Scissors game in C++

This is my code for a simple Rock, Paper, Scissors game. Users have the choice of playing against a computer, or watching a "computer player" play another "computer player". The code for the computer ...
1
vote
3answers
63 views

Converting a double to a std::string without scientific notation

Problem I need to convert a double to a std::string which contains no scientific notation and no unnecessary fillers. Using ...
3
votes
2answers
89 views

Tic Tac Toe game in C++

I'd like to get an opinion on the code I've made for a Tic Tac Toe game in C++. I'm pretty new to C++ but I'd like to improve. I haven't been able to think of any improvements. One bug I'd like to ...
6
votes
1answer
61 views

Having fun with JNI: formatting a number

I attempted some (easy) coding with Java Native Interface. This is what I have: six_pack_Neatifier.h: (autogenerated by javah) ...
1
vote
2answers
44 views

Restructuring nested maps

I am in the process of making an assembler and one of the needed steps is actually getting the opcode from a table. However, the instruction set I'm working on has a handful of different addressing ...
1
vote
1answer
38 views

Casting between types for shared_ptr

I'm implementing an Entity-Component-System. Basically, an entity is a wrapper around an ID, a component is just a POD struct, and a System is a class that does work on components corresponding to the ...
2
votes
1answer
73 views

SFML Pong Game Performance

I was hoping I could get some feedback on performance of my animations overall. It could just be me but I keep getting a bit of lag despite being at 60FPS constantly. Objects on screen seem to tear a ...
6
votes
1answer
56 views

Displaying a menu

I created this for a project at class, and I already turned it in so I know it's too late for changing it and whatnot as it's the end of the semester, but I want to know from the community how well I ...
7
votes
1answer
83 views

SmartRandom bombing strategy for Battleship game

Now that I have some infrastructure in place to test it (see my Battleship test framework and the updated GitHub project for the full context), I have finally written a non-trivial bombing strategy ...