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

learn more… | top users | synonyms

3
votes
0answers
27 views

Storing large amount of iterations (of multiple variables) in a single object

I am writing a simulation program in C++ which must be able to iterate over multiple variables over multiple classes (according by user input). The basic design of the device is as following: ...
3
votes
1answer
32 views

Seed to Flower/Mushroom

Here you see my first ever "program"! What it is supposed to do is explained in the comments, because it was already in there when I started making it. I am totally new to C++, I have about 2 weeks of ...
5
votes
1answer
26 views

Basic String class

I wanted to create a basic String class that will hold a CString and have: constructor, destructor, copy constructor ...
-1
votes
0answers
18 views

Ping Pong game c++ [on hold]

So I'm coding a simple ping pong game. I've started doing the if statements for the ball collisions and I'm a bit stuck. I want the ball to bounce of the rackets when it comes in contact with them. ...
1
vote
0answers
28 views

Simple Win32 console library (mimicking almighty SFML)

How can I improve it? ...
3
votes
2answers
28 views

Cubic “bezier” curve of grade n

This is code I wrote for calculating bezier curves as quickly and RAM efficiently as possible. I would like to know if there are faster ways to optimize anything, because I am very new to C++ and ...
3
votes
1answer
47 views

Simple concurrent freelist

To become better acquainted with the Intel Parallel Studio XE profilers I'm currently messing around with a simple concurrent freelist. I'm fairly certain that it's thread-safe. It uses Acq/Rel ...
4
votes
2answers
60 views

Hardcoding matrix multiplication

I was doing a problem, SPOJ: FLIB. My code was running slow (getting Time Limit Exceeded error) when I was using Code1. However, my code accepted within the required time limit when I hardcoded the ...
5
votes
2answers
57 views

Tile rendering/position updating performance

The code below grabs the contents of a .txt file, and scans each character of it, using that data to create a tile set. My main concern, is that for each loop, I am opening and closing a file each ...
5
votes
2answers
60 views

Makefile for C++ OpenGL with GLFW and glad

This is a makefile I wrote to compile a simple OpenGL test project which is going to use the libraries GLFW and the C library glad.c. ...
4
votes
1answer
46 views

Snake console game

I made a simple C++ snake game, and I want some advice from you: what is good, what I have to improve. One main problem is that flipping (which you'll notice if you play it). ...
10
votes
4answers
558 views

Knowledge is power

Resurrecting my C++ saga, I was given this project for my CS2 class: This problem considers several ways to compute \$ x^n \$ for some \$ n \ge 0 \$. Write an iterative function ...
6
votes
1answer
44 views

C++14 Async Task Scheduler

I'm not sure if this site has the right audience for anyone to be able to respond to this, but I wrote a header only scheduler which schedules a task to be run in the future on another thread: ...
4
votes
2answers
73 views

OOP Blackjack in C++

I finished my Blackjack OO game and I'd like to get my OO skills reviewed. ...
7
votes
1answer
45 views

sha1sum implementation in C++

I rarely program C++ in anger, and considered myself somewhat rusty, and certainly not up to speed on C++11. For a bit of exercise, I thought I'd try implementing sha1sum, as wasn't really up to speed ...
3
votes
0answers
21 views

Entity component system for text based console on Windows

I have written this code base on AsciiEngine How can i improve this code ...
8
votes
2answers
310 views

Calculating epoch seconds

Below I have code that calculates epoch seconds. It is built to try to change run time checks into asserts in order to give performance in production. I want to make sure all the edge cases are ...
9
votes
2answers
214 views

Meta-programming template for collection statistics

I find that I often want to calculate summary statistics from collections of data and decided to create a template to do that. I'm interested in a general review, but I also have some specific ...
3
votes
3answers
245 views

Convert an array to a binary tree

I wrote this code in C++ to convert an array to a binary tree. For instance, int nums[] = {7,5,9,1,7,3} to a binary tree (root-7, root's left child-5, root's right ...
0
votes
0answers
39 views

Texture framework library [on hold]

I'm creating a C++ framework that could be really useful to the community. I'm writing the best I can with the new C++11 and C++14 standards but I'm not really sure about some things related to ...
5
votes
1answer
58 views

Effective use of branch prediction in terrain generator

I am trying to learn how branch optimization works. For an experiment, I have a recursive fractal terrain generation and I have moved all if statements to binary ...
3
votes
1answer
74 views

First OOP TicTacToe game

This is my first program using classes. How could this be improved? ...
2
votes
1answer
50 views

Converting array of bytes to the hex string representation

Is it possible to make the hexStr function faster? ...
1
vote
0answers
35 views

Finding the number with the greatest number of divisors and lowest value [on hold]

The program is finding the number with the greatest number of divisors and lowest value. I have been working on it for about 7 hour and it keep saying "Time Limit Exceed", so I'd like to show me how ...
4
votes
2answers
192 views

C++ smart pointers and classes

I've started learning C++ recently and want from what I've gathered smart pointers are the way to go when storing stuff on the free store. I want to make sure I've got the basic hang of C++(11) ...
3
votes
2answers
98 views

Hacker Rank - Lonely Integer

This is the problem statement for Lonely Integer. There are N integers in an array A. All but one integer occur in pairs. Your task is to find out the number that occurs only once. Input Format ...
3
votes
1answer
60 views

Seeking proper system for pairing types

My code below ensures that only land animals can be a "representatives" for Land while only ocean animals can be representatives for ...
1
vote
1answer
42 views

C++ Readable serial constant range counter [closed]

What I am asking here is about code readablity. Consider the following code: ...
0
votes
0answers
50 views

Hackerrank Circle City [closed]

I've been trying to solve this relatively simple challenge, but I can't figure out where the problem in my code is. Here is the reference question: https://www.hackerrank.com/challenges/circle-city ...
6
votes
1answer
86 views

HackerRank - Insertion Sort - Part 2

This is the problem statement for Insertion Sort - Part 2. In Insertion Sort Part 1, you sorted one element into an array. Using the same approach repeatedly, can you sort an entire unsorted array? ...
0
votes
0answers
24 views

How do I print out the text file by reading strings and scores? [closed]

Alright, I will do my best to ask this kind of question. This is a homework assignment, so I gotta learn the hard way. I'm in a class that we are learning C++11. It is basically new to me so I'm ...
13
votes
2answers
201 views
+50

Hangman on the C++ommand line

I'm wondering if my code is just a tad too long to post here, but if the only consequence seems to be getting high-level reviews, then that's perfectly fine. This is my implementation of Hangman in ...
3
votes
0answers
59 views

any that can hold arrays

I've tried to make a better any than before: ...
1
vote
0answers
20 views

Max independent set of a sequence

This is the code I've written to find the maximum-weight independent set of a graph path. It's a standard problem with a well-known dynamic programming solution of linear complexity. Since it's a ...
1
vote
2answers
45 views

Generic 2D engine for simulation

I'm using SFML to manage my windows and I'm writing this engine to visualize some PSO work. I'm trying to make it generic enough that I can extend it for other simulations later on and keep it as ...
4
votes
2answers
51 views

Timus Online Judge Problem 1001 - “Reverse Root”

The problem statement can be found here. Description (short): Input The input stream contains a set of integer numbers \$A_i\$ (\$0 \le A_i \le 10^{18}\$). The numbers are separated by any number ...
1
vote
0answers
28 views

Text-based Snake game on Window - follow-up 2

Previous question: Text-based Snake game on Window - follow-up Summary of improvements: Corrected the names of classes and members data Implemented Console ...
4
votes
2answers
445 views

Game of Life class

I'm a beginner in C++, and I'd like you to review the class I wrote for the Game Of Life. GameOfLife.h ...
3
votes
0answers
32 views

Text-based Snake game on Window - follow-up

Previous question: Text-based Snake game on Window Summary of improvements: Removed unnecessary functions such as clearScreen() Added new ...
2
votes
1answer
48 views

HTTP client similar to cURL

I'm writing my own HTTP client, kinda like cURL. (I already know I'm reinventing the wheel, this is more or less getting an inside look of HTTP 1.x before 2 becomes a thing.) So far pages download ...
6
votes
2answers
80 views

Merge sort in C++ with iterators

I implemented merge sort with C++ and would like to get some feedback. ...
4
votes
1answer
33 views

Dynamically adding QLineEdits and then copy text from them to vector in right order

Here is how it looks at the beginning: And after I can add random counts of line edits: Or delete them: The main purpose is the possibility to add or delete ...
3
votes
1answer
57 views

Calculator with single line input - follow-up

Part 2 of this question. I've rewritten most parts of the code, for the better I hope. The code now has some more logic and less readability. Functions included in the calculator: Addition User ...
9
votes
4answers
394 views

Calculator with simple input

This is "my" version of a basic C++ calculator, that requires a single line input (like 1+1) to calculate the result. I have been (self)learning the language for 2 months now. I don't pretend to have ...
3
votes
2answers
291 views

Stack Implementation

I would like comments on my implementation of a stack: ...
3
votes
0answers
61 views

Compile Time Constant Map

I have implemented this compile time map as a way to learn templates and constexpr classes: ...
6
votes
2answers
77 views

Harmonic partial sum calculator with multithreading

I wrote a program which computes the harmonic partial sum to N terms with multithreading capability. I've been working on this to sharpen my C++ skills for the upcoming semester. Just wondering if ...
1
vote
0answers
20 views

Technique to destroy classes and mutexes used by several concurrent threads [closed]

I would like to get some advice and reviews regarding to the following code: Code 1: ...
4
votes
2answers
81 views

Text-based Snake game on Window

How can I improve this game? ...
6
votes
1answer
59 views

Making prime (sieve) code faster and able to run on big numbers

For an input triple (a, b, c), the task is to count the number of integers in the inclusive range [a, b] which have c distinct prime factors. This entails factoring each of the numbers in the range ...