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

learn more… | top users | synonyms (1)

6
votes
4answers
255 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
1answer
48 views

Simple RPG Skeleton, Part 2 - The Entity, and a SpecType - follow-up

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
54 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
74 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
76 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
98 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
123 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
102 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

Drawing a checkerboard with FLTK

This is my first attempt to draw using FLTK libraries *: ...
13
votes
2answers
408 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
283 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
443 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
82 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
29 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
59 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
294 views

C++ Array with iterators

I wrote an Array class with iterators: ...
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
82 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
76 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
91 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
73 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 (...
-1
votes
0answers
47 views

Text-based RPG game skeleton [closed]

I'm new to programming and I wanted to try my hand at it. Right now I have not gotten very far, but I'm working on the foundation. The model I'm following for this game is borrowed from other ...
4
votes
1answer
37 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 ...
8
votes
2answers
90 views

Writing waypoints to a file

I have generated code which reads a file containing ways, take the individual waypoints and writes them into a new file, but only if the waypoint is not already present. At this moment my program ...
1
vote
2answers
52 views

Node-based rendering

Recently, I started wrapping Meshes and Transform classes into new ones, but by doing this I came upon a problem: I needed to ...
10
votes
6answers
506 views

Find the perfect numbers within the range of 1 and a chosen number

My program is complete and working, but I would like second opinions on it. The program prompts the user for a positive value that will serve as the maximum for the range that will be checked for ...
2
votes
1answer
57 views

Making sequence unique with removal records

I'm working on a tool to detect all exact tandem repeats in a DNA/RNA sequence. Part of the algorithm requires finding Longest Common Extension (LCE) values, which although can be computed in constant ...
5
votes
0answers
54 views

Find all the primes less or equal than N

This is not a novel interview problem. But I want to address it with the following points: Implement the algorithm with Object-Oriented Design principles in mind. Optimize the solution, if there are ...
4
votes
1answer
83 views
+50

Optional base class template to get conditional data members

In generic code, I sometimes want to conditionally add a data member to a class template. Writing separate template specializations scales as 2^N for ...
6
votes
3answers
652 views

Random number generation seeding in C++

I wrote a small function to return a random in a given range: ...
2
votes
2answers
98 views

Breadth-First Search heuristics to find solution to Water Jug Challenge

I started learning AI recently. In AI, searches should be avoided and everything in AI is a search problem. One of the easiest problem where we could use general AI search techniques is the water jug ...
-1
votes
1answer
40 views

DDA Line Drawing Algorithm

I am using WinBGIm. ...
4
votes
1answer
106 views

2D Fenwick-tree with combinatorics and modular arithmetic

This is a contest problem; Description: In the winter, children started to build snowmen. The snowmen were becoming adorable, except for a detail: none of them had a nose. The king, touched, ...