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

learn more… | top users | synonyms (1)

2
votes
0answers
10 views

Octree creation for Barnes-Hut algorithm

I am trying to implement quadtree for my barnes-hut algorithm implementation. I am not sure that the code I've wrote so far is good implementation - it is dirty, and tend to be slow. Of course I am ...
1
vote
0answers
19 views

Union Find implementation

I am trying to complete this challenge. The user should enter a sequence of instructions, = to link two numbers, and ? to query ...
4
votes
2answers
39 views

Is this the right way to implement a simple hash table in C++?

Does this look like a proper implementation of a hash table in C++? Any errors anyone can find? Thanks in advance (: ...
0
votes
1answer
18 views

Handler for incoming network packages

I want to let you look through my NetHandler which is basically the component which gets notified when a full packet arrived (not like tcp-packet but my own type of ...
4
votes
0answers
23 views

Variant class that I don't think is missing anything

My goal is to learn a bit more about Generic Programming in C++. So, one of the trickiest things I've heard you can do is creating a Variant class. This took me a while and I needed to read and study ...
-4
votes
0answers
25 views

This is my working code of a simple game called - “rock,paper,scissor” [on hold]

.I wanted to know is there any way to add classes to show inheritance in this program? If yes,,help me in doing so asap ! ...
0
votes
1answer
41 views

C++ lazy constructor

I'm implementing a lazy constructor in C++. The goal is that for a type T, lazy<T>(args...) returns a callable object ...
0
votes
1answer
40 views

C++ simple event system

I posted an earlier version of this code a couple of days ago, so it's the updated version of the code posted here. ...
1
vote
0answers
19 views

Associativity problems in math expression [migrated]

With the following simple C++ exercise ...
4
votes
3answers
107 views

Simple Pool Allocator

This is a simple pool allocator, based (to at least some degree) on a previous answer. The basic idea is pretty simple: allow a user to allocate objects of some type quickly (in relatively large ...
1
vote
0answers
33 views

Tool for composing functors

What do you think of this code? ...
0
votes
0answers
13 views

Lazy segment tree implementation

I wrote a C++ implementation of a segment tree (I wrote it for an arbitrary function, "lazy" version) and I want so much to ask for a review. I'd like to know how I can make it better, especially the ...
0
votes
0answers
33 views

Segment tree implementation in C++

I wrote a C++ implementation of a segment tree (I wrote it for an arbitrary function, not "lazy" version) and I want so much to ask for a review. I'd like to know how I can make it better, especially ...
3
votes
0answers
19 views

Sparse table implementation

I wrote a C++ implementation of a sparse table (I wrote it for an arbitrary function) and I want so much to ask for a review. I'd like to know how I can make it better, especially the consistency of ...
2
votes
0answers
36 views

Any class implementation - follow-up

Based on the previous question, I have improved it to make it insert regular function. Also, I have implemented a new template approach to obtain the signature from any function by testing its ...
3
votes
1answer
69 views

Simple event system

This is a class which provides a simple event system mechanism: ...
-2
votes
0answers
33 views
2
votes
2answers
63 views

Adding two singly linked lists in C++

I took a challenge from a web site. I aim to have a runtime performance as good as possible. My solution was accepted, though I think it is not the most efficient because I saw others having a faster ...
0
votes
0answers
22 views

Adjacency List Graph Implementation for search

I wrote this adjacency list graph implementation to learn about implement path finding and graph search. I'm looking to fix any coding style / best practice issues, and performance issues. Also, the ...
-1
votes
0answers
15 views

Solving the precedence constrainted biknapsack [on hold]

I don't have a stong background in combinatorial optimization nor programming and I have to write some code to solve the bi knapsack (2 capacities ) with constraints of precedence.. I've been working ...
0
votes
0answers
29 views

create only one instance with std::weak_ptr and enable_shared_from_this

I need to have a specific instance which is not destroyed (short-lived singleton?) I do not know at which point of my program the class needs to be instantiated nor do I know when it needs to be ...
4
votes
3answers
757 views

ToDo List Program Efficiency

I created a simple todo list program in C++ with the ability to store multiple lists, and add and delete list elements. I'm looking for suggestions on how to make it more efficient, obvious ...
0
votes
0answers
20 views

Storing and maintaining function pointers via a plugin like system

I have to work with a lot of functions for a library. I encapsulated these functions into structures, e.g. DistFunction stores two function pointers and the name of this structure (which is necessary ...
-2
votes
0answers
13 views

Problems when i change path for listing files [closed]

I am trying to get all the files from a folder with their size. The problem is that i change the path from current directory, it can't find the size of files. It works only for the current directory, ...
-3
votes
0answers
29 views

Variable s gives me a negative number [closed]

It's the second Euler project ...
5
votes
1answer
45 views

Lazy String splitter in C++

I created a string splitter in C++. It splits a string in a lazy fashion and makes use of forward iterators to sequentially supply the next token from the string until it runs out of tokens. ...
3
votes
1answer
53 views

Custom GUI Slider class

I want to improve my slider class as much as possible. Is this acceptable code for a slider? I've tried to comment as much as I can. If you want to find out more about the ...
2
votes
1answer
55 views

Searching a maze using DFS in C++

I have started learning recursion and search algorithms, especially DFS and BFS. In this program, I have tried to make an implementation of a maze-solving algorithm using DFS. The program is working ...
-3
votes
0answers
19 views

Read from Text and Save to Two or Three Variables [closed]

Currently, I have a program that reads from a text input file that is expected to be in the format: ...
-2
votes
0answers
35 views

Am I writing this insert function for a linked list in c++ efficiently? [closed]

By efficiently I mean, using as little lines of code and if there are any errors please point them out. Thank you. ...
2
votes
1answer
78 views

C++ Console variables

I've written some code for console variables. They support different types e.g. integer, string, vector, float, etc. Is there a better way to do this? Like with an interface and a class for each ...
3
votes
1answer
79 views

Tic-Tac-Toe game in C++

I'm new to C++ and made this basic Tic-Tac-Toe game from scratch. I would like to know if there are simpler or more efficient ways of doing the things that are covered in the code. As I said, I'm new ...
0
votes
1answer
30 views

p0-Pollard implementation

I should implement p0-Pollard with C++14 and a good algorithm. How may I improve my code? ...
4
votes
4answers
268 views

Removing duplicate characters from a string

I implemented a function removeDuplicates which takes 1 parameter, a std::string, and returns a ...
0
votes
2answers
68 views

Student class with std::string

I am writing a class that has a few std::string as a member. I can't find clear guidelines on how use them in a safe way. Are ...
2
votes
1answer
54 views

Parsing a string containing arithmetic operations in prefix notation

This is a piece from the complete program. What it does is parses mathematical expressions of the form (+(*3,x),5) to 3*x + 5 ...
4
votes
1answer
74 views

Counting sort using STL

I'm trying to learn to use the C++ Standard Library and some of the modern C++11 features. Can someone review my counting sort algorithm below and critique my style/algorithm/use of the STL? Thank ...
3
votes
1answer
52 views

Determining if a string is a palindrome of a permutation

I wrote code to determine if a string is a palindrome of a permutation. This exercise was taken from Cracking the Coding Interview. I'm looking for any tips on improving it. ...
1
vote
0answers
29 views

Searching a Maze Using DFS [closed]

I am new to recursion and searching algorithms and am trying to implement a maze searching program using DFS. I have tried troubleshooting the issue, but there seems to be an error with my code. Any ...
1
vote
1answer
82 views

Implementation of Dijkstra's algorithm in C++

This is my implementation of Dijkstra's algorithm. Could you tell me what am I doing wrong and what should be fixed? I was not sure how to keep track of the shortest outgoing edge from a node and I ...
-2
votes
0answers
11 views

Error in XCode: Reference to overloaded function could not be referenced. [closed]

I am trying to write a program that will compute the average and sort a certain number of grades a user inputs. I am working with dynamic array allocation. I feel confident in my code, but Xcode is ...
1
vote
1answer
58 views

Implementation of Prim's algorithm in C++

Could anyone comment on what could be done better and if I made any mistakes? ...
1
vote
0answers
31 views

A stack optimized for filter queries, written in C++ preprocessor

Given a stack with N elements and a query Q we need to find all elements of stack, for which ...
5
votes
1answer
67 views

Computing the total different between a pixel and its neighborhood

I have C++ code which written for mex in MATLAB. It used to compute the total different between a pixel and its neighborhood (8 neighborhood in my code). The code ran and gave me an expected result. ...
4
votes
2answers
112 views

Calculating pi by adding areas of thin rectangles

I wrote a small program for fun to try to prove Pi by taking a certain precision and radius and using it to calculate the area of the circle. My method should be giving me an area that is just ...
3
votes
1answer
142 views

Race car with falling objects that make the car go back to its initial position game

I saw a game made in Python and PyGame in a tutorial, so I thought I'd make a game like it in Allegro5 and C++. I think I made my style a little better than my style before since I stopped putting ...
4
votes
0answers
47 views

Any class implementation

I was inspired from question here, to implement function container that holder any kind of function by using boost::any, I have carried on and extend it further to make the functions holder accept ...
3
votes
0answers
46 views

Matrix template with basic operations and utilities

I implemented a basic Matrix class for additions of matrices, multiplication of them, and multiplying every entry of matrix by constant, ...
1
vote
2answers
30 views

Luhn Algorithm in C++

How can I improve or shorten my implementation of the Luhn algorithm? ...