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

learn more… | top users | synonyms (1)

6
votes
1answer
154 views

Simple RPG skeleton - Part 1

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
29 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
42 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! ...
0
votes
0answers
18 views

C++ Multithreaded Ip Range Port Scanner [on hold]

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 ...
7
votes
1answer
81 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
45 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
14 views

Code for Accessing a function from Unmanaged dll [on hold]

The following code accesses a function from an unmanaged dll. ...
5
votes
2answers
270 views

C++ Array with iterators

I wrote an Array class with iterators: ...
3
votes
2answers
47 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
41 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
75 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
28 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
73 views
3
votes
3answers
69 views

Populating a vector with alternating numbers

This code inserts the number 4 into a vector's even indexes. ...
4
votes
0answers
81 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
65 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
35 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
42 views

Text-based RPG game skeleton [on hold]

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 ...
1
vote
0answers
19 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
338 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 ...
-1
votes
1answer
32 views

Logical operators on int [on hold]

Suppose I have the following class: struct C{ C():i{0}{} int i; }; In C++, do you consider bad C-ish style to deal with the ...
3
votes
0answers
61 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 ...
0
votes
0answers
20 views

C++: Using multimap to sort objects and change key for a specific object later [on hold]

I have a list of objects. This list is traversed using an iterator (pointer) and for every object that is retrieved I assign it a random "rank" such that, each rank-object forms a std::pair. I pass ...
6
votes
2answers
70 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
50 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 ...
9
votes
6answers
492 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
56 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
51 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 ...
2
votes
0answers
40 views

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
644 views

Random number generation seeding in C++

I wrote a small function to return a random in a given range: ...
2
votes
2answers
92 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
39 views

DDA Line Drawing Algorithm

I am using WinBGIm. ...
4
votes
1answer
104 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, ...
0
votes
0answers
46 views

Integrating depth images into an SDF

I want to improve the following peace of code as much as possible, both regarding to speed and other aspects I may not know about. Since I have learned C++ myself, there are probably many things to ...
5
votes
2answers
82 views

Displaying all permutations of a string

I am using this code to display all the permutations of a given input string. Any advice/solution will be very helpful. ...
5
votes
2answers
68 views

Scanning for open ports

I made what started out as a web browser but now is a scanner for open ports. I wanted to know if you think this is a realistic or a unreliable tool for port testing. I found some open ports on my ...
6
votes
3answers
496 views

Largest palindrome that can be made from a product of 2 3-digit numbers (Project Euler 4)

This is my solution to Project Euler #4, which asks for the largest palindrome that can be made from a product of 2 3-digit numbers. I have done a brute force method, but it takes around 10-20 seconds ...
5
votes
1answer
58 views

Cancellable futures, interaction with throwing destructors

I'm reinventing std::future from scratch (for an upcoming talk). I'd like to incorporate as many of the latest and most likely-to-succeed proposals as possible, and ...
2
votes
0answers
33 views

Code Chef problem COOKMACH

Firstly, I got the solution for this question in CodeChef, but I noticed one thing which still confuses me. This was the code which was accepted as correct. ...
0
votes
1answer
29 views

Method of uniquely identifying classes

I have written the following class to allow me to uniquely identify classes in C++, and I was wondering if there are any better ways of going about it. ...
7
votes
2answers
76 views

Series sum calculator

This is my program currently to calculate sum of following series: $$\frac{x^2}{2!} + \frac{x^4}{4!} + \frac{x^6}{6!} \dots$$ ...
2
votes
1answer
42 views

Boost::pool based STL vector allocator

I wrote an STL allocator which uses boost::pool to allocate the memory for std::vector container. This is my first time I ...
3
votes
1answer
69 views

Calculating the sum of array elements to the left and right

I am using C++ to code the following logic: An Array is given we have to traverse the array such that sum of array elements to its left must be equal to sum of elements to its right. BTW this is ...
9
votes
0answers
70 views

C SIMD Matrix Multiplication

I recently started toying with SIMD and came up with the following code for matrix multiplication. I would greatly appreciate if someone with more experience with these things could tell me how far ...
8
votes
1answer
267 views

Integer to Roman Numeral converter

I have implemented an Integer to Roman Numeral converter that converts any number in the range \$[1 \le x \le4999]\$ to its Roman number equivalent. Any comments on improving my code style or ...
3
votes
1answer
104 views

Solution to challenge of making a list

This is the answer to this challenge: Description Thanks for that list you made me, my thoughts are way more organised! I've got a few problems though that I thought you might be able to ...
5
votes
0answers
36 views

Template integer range, version 2

This question is a follow-up. The original question was itself a follow-up to an older question by @LokiAstari. The idea is to provide a compile-time integer range. This version incorporates ...
2
votes
0answers
39 views

Efficient Sets and Maps with Treaps

I wrote up a Treap implementation to serve as the base class for a bunch of augmented data structures (interval sets, plane (2D) sets, order statistic trees), replacing my RB-tree base. Some ...
2
votes
2answers
112 views

Wrapping primitives in a simple class

I made this Primitive class recently for my OpenGL engine. It basically wraps all basic primitive shapes, like cones, toruses, and cubes, which the user can use for ...
11
votes
1answer
124 views

I made an implementation of std::deque, in my own way…?

In fact, entire deque header, though. According to Wikipedia, common implementations of std::deque include: Storing deque contents in a circular buffer, and only resizing when the buffer ...