C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.
1
vote
1answer
7 views
Lockless SCSP queue
I'm looking for a code review on a class that I've written. It was my first attempt at lockless programming and I'd love any feedback I can get.
...
2
votes
2answers
26 views
Library for C++ programs
Here is some of the code in my library. If there any inefficient things in my code, let me know.
InverseAPI.cpp:
...
5
votes
2answers
105 views
Stack Implementation in C++
This is my first template implementation. I'm trying to learn C++ and Algorithms. Any constructive criticism on code quality, readability is welcome. Everyone has their own style, but there are ...
2
votes
1answer
21 views
A selection pattern for C++11
In simulating physical equations (such as fluid dynamics) it is common to write an application that deals with 1, 2, and 3 dimensions. A common C/Fortran approach is to make all vectors (for example) ...
1
vote
2answers
44 views
Implementation of Brent's Algorithm to find roots of a polynomial
I made a program that contains a root-finding algorithm for polynomials as a function and contains 3 test polynomials. The algorithm is Brent's method and is based entirely off the pseudocode from ...
2
votes
2answers
57 views
DeepPtr: a deep-copying unique_ptr wrapper in C++
When using the pimple idiom it is necessary to represent your "impl" as a forward declared pointer in the header file. This necessitates a lot of boilerplate code to implement the rule of five.
...
2
votes
2answers
38 views
C++ Minimalistic Unit Testing Library
I was looking for a unit testing library for C++, and I found many. Unfortunately, I decided I didn't want to use any of them. I decided to make my own.
This is the result. I made heavy use of the ...
1
vote
0answers
32 views
Text-based RPG game in C++
This is a text-based RPG game I've made in C++ and would love some review on it. I am a 100% complete newbie with maybe 2 weeks of C++ experience so I'd love some lessons on what I did wrong and how I ...
4
votes
2answers
87 views
Project Euler 18/67: Maximum Path Sum Solution
I wrote my solution to Project Euler #18 and #67 in C++ (which I'm relatively new to), and was just wondering what everyone else thinks of it. It executes in 3-4ms and works flawlessly (even for ...
2
votes
2answers
37 views
C++ Optional Implementation
I haven't done much programming in C++, so I figured I'd try making an Optional class. I'm mainly concerned that I didn't follow good conventions or that I didn't ...
6
votes
0answers
26 views
Nothing compiler/interpreter, Part 2
Part 1
I've followed some of the suggestions:
Adding newlines to error messages
Implementing options (I decided to use boost instead of getopt)
Using strerror for fstream failure
Allow multiple ...
6
votes
5answers
517 views
Temperature Converter
This is an implementation of a practice problem from cprogramming.com: Temperature Converter Challenge
The problem:
In this challenge, write a program that takes in three arguments, a start ...
4
votes
2answers
64 views
Simple RPG Skeleton, Part 2 - The Entity, and a SpecType
This question is a followup to Simple RPG skeleton, Part 1 - The Character.
This is the second "part" of my development of this skeleton, and it now includes two new classes, ...
0
votes
0answers
7 views
custom allocator - microsoft std::map implementation deallocates the same element twice, gcc works fine [migrated]
The idea was to have a reusable stl-compatible allocator that is simple to use and won't use the free-store in performance-critical areas of the software.
Here's some test code (very basic testing):
...
3
votes
1answer
39 views
A less verbose const_cast
Motivation
const_cast is a beast that I seldomly encounter. But when I do so it is mostly a bad experience.
Nobody knows what most of the C++ programmers do but ...
-3
votes
0answers
35 views
Finding Euclidean Distance in c++. [on hold]
I would like to create a c++ program that can help me to find the euclidean distance between 2 randomized vectors. This is what i got so far.This program can run but still fail to give me the correct ...
5
votes
1answer
56 views
IP Range Port Scanner
I've been working on this project to learn networking and concurrency as well as C++11 practices. I'm just looking for a general code review.
...
6
votes
2answers
91 views
Reading awkward text fields
I have written nested while loops to read in some of the columns in a text file that looks like this:
...
11
votes
1answer
75 views
Compile-time list in C++
Everything is evaluated in compile-time. You will need a C++14 compiler. The compilation time is quite long, and with a bigger list input, you'll get some error messages like ...
5
votes
1answer
78 views
An attempt on unit testing in C++
I have no much experience with C++, so it is about time to start actually doing something about it. All in all, I coded this tiny unit test library:
assert.h:
...
4
votes
1answer
103 views
Base-2 representation using C++
I'm preparing for a test and came across this exercise. If possible, dissect this and point out any flaws in it, keeping in mind time complexity.
In base \$-2\$, Integers are represented by ...
6
votes
3answers
584 views
C++ Stack using template
I'm learning C++, so I wrote a stack with the help of templates. I'm wondering if there is anything I can improve or if I did something vastly wrong.
Stack.h
...
6
votes
1answer
126 views
Boost.Spirit UTF-8 string literal parser with escape support
I wrote (as part of a greater work) a Boost.Spirit grammar that would parse string literals, including support for the various escape sequences known from C/C++ (...
2
votes
3answers
106 views
Music collection with lyric songs and instrumental pieces
I have problems with dealing with derived classes that inherit from the same base class.
I have 2 types of songs:
Songs with lyrics that have: Title, Tags (sad, happy etc.), lyrics (one line), ...
2
votes
0answers
26 views
C++ std::setprecision in C# [migrated]
I'm picking up C# by porting some legacy C++ code and would like to keep the output identical. What used to be something along the lines of
...
3
votes
1answer
59 views
7
votes
1answer
65 views
13
votes
2answers
413 views
Full C++ Snake game
I managed to finish my approach on the legendary Snake game. You move around with the WASD keys. I would like to hear your opinion and maybe ideas on how I can improve frame rate because now it sort ...
6
votes
4answers
284 views
Getting a scrabble score from a word
My program is complete and runs, and gives me the output I expect. For example, if I enter the string "HELLO" I should get 8. ...
10
votes
3answers
444 views
“Nothing” interpreter/compiler
This is an implementation of the Nothing programming language. The language spec is as follows:
Design philosophy
In the current software industry focus lays on solving complex
problems by ...
18
votes
4answers
2k views
Simple RPG skeleton, Part 1 - The Character
I've been on a quest to learn C++, and to learn, I've started building a small RPG skeleton to help myself learn the language. I've tried to make sure that I've followed C++ styles/standards ...
4
votes
1answer
52 views
Sprite cache and Directory reader
I have been fiddling around with creating my own Sprite Cache.
Currently, I am using the C header file, dirent.h, to open up a directory and load all .bmp files. I ...
2
votes
2answers
83 views
Hangman game school project
This is a school project and took me a while to write the code. Any help to improve my code is welcome!
...
-1
votes
0answers
30 views
C++ Multithreaded Ip Range Port Scanner [closed]
Been working on creating a multi-threaded port scanner that can scan an IP range. However my results are being skewed. I feel as if I have a race condition in my code but I cant seem to find it.
All ...
8
votes
1answer
107 views
Count number of isosceles triangles in a set of points
Given a set of points, what is the number of isosceles triangles that can be formed with the combinations of all points in the set?
It is certain that 3 collinear points never exists in the set.
...
2
votes
0answers
60 views
Tic Tac Toe algorithm
I made a Tic Tac Toe game, but I think there's a lot of hard-coding and useless variables. Can you check it out and tell me what I can improve on? It works, but it has a couple of bugs.
...
-4
votes
0answers
19 views
Code for Accessing a function from Unmanaged dll [closed]
The following code accesses a function from an unmanaged dll.
...
5
votes
2answers
296 views
3
votes
3answers
78 views
Encode a string using Caesar's Cipher
My program is complete and running, but I would like second opinions on how I can make it more efficient. The program prompts the user for the message and the amount s/he would like to shift the ...
4
votes
2answers
46 views
Prompt user for input then create an acronym from it
My program is complete and working, but I would like second opinions on it. The program prompts the user to enter something like a phrase or some words. Then it will create an acronym of what was ...
1
vote
2answers
83 views
Implementing object associations
I tried to find a generic way to deal with associations. I ended up with this code which seems to fit my needs:
...
2
votes
2answers
29 views
Send and receive data code using OpenSSL
I need to send and receive data. Here is solution for my original problem. I want to know how safe my finished code is and how I can improve it. Here is my first try. Now I need to get review for my ...
5
votes
2answers
77 views
3
votes
3answers
73 views
Populating a vector with alternating numbers
This code inserts the number 4 into a vector's even indexes.
...
4
votes
0answers
93 views
Factory with raw pointers
I'm designing a Factory in C++ with raw pointers, but I'd like to use smart pointers when possible as is recommended with the Factory pattern in newer C++. Unfortunately my compiler is a bit old (gcc ...
3
votes
1answer
74 views
Solving Project Euler problem #60 in C++
I have implemented a solution to Project Euler problem #60. In summary, the problem asks to find the smallest sum of a set of five prime numbers such that the decimal strings of any two numbers in the ...
2
votes
1answer
39 views
Get K most frequent tokens from a token stream
This is an interview problem:
Given a token stream, find the K most frequent tokens in real time (the order of these k tokens does not matter).
My approach:
Use a hash table (...
4
votes
1answer
39 views
Adding/changing ID3 tags to media files with “artist - title” format
This code puts or changes ID3 tags to media files based on their file names. It assumes the files are in this format:
morbid angel - maze of torment.mp3
The ...
5
votes
3answers
341 views
SPOJ solution of GRAVITY
I am solving problem GRAVITY on SPOJ. Each test case is a rectangular ASCII grid of dimensions m × n, and you have to determine ...
3
votes
0answers
69 views
An attempt at implementing Maybe in C++11
I gave a shot at implementing Maybe for C++ and a slight twist in my implementation is that it uses thread_local static instance ...