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

learn more… | top users | synonyms (1)

0
votes
0answers
3 views

Binary Search Tree implementation with Rule of Three C++

I am started to code in C++ and try to implement a simple BST data structure. Since at the moment I am learning about the Rule of Three, I tried to implement it in my code. Yet, I realise that my code ...
0
votes
0answers
2 views

Depth Manager System

I have created a template class that manages instances by order of depth (least to greatest) and first added to least added. It allows for a user to add and remove instances, and it allows for the ...
1
vote
2answers
33 views

Simple and concise new iterator design

I came up with a new iteration pattern for a C++ API that aims at simplifying client code. Basically, when developers have an iterable object myCollection, they ...
-3
votes
0answers
23 views

How to access elements of an object created using vector [migrated]

I was trying to create objects to a class dynamically using vector. class lib { int a; }; THen using this to make objects. ...
0
votes
4answers
54 views

std::string implementation

Following is my attempt for a simple implementation for the std string class. Please review my changes and share your feedback. string.h ...
3
votes
0answers
30 views

CMake build system

I wasn't quite sure where to go with this, and this seemed to be the best place I could think of so I thought why not. I threw together a build system for C++ projects today using CMake and I wanted ...
3
votes
2answers
219 views

Counting trains by type code

A train operator has decided to hire an observer to track the different types of trains transiting at a major train platform in Europe. Write a program, using a for loop, to track the different ...
-1
votes
0answers
15 views

Check whether the code is correct for me [duplicate]

Using C++ A train operator has decided to hire an observer to track the different types of trains transiting at a major train platform in Europe. Write a program, using a for loop, to track the ...
0
votes
0answers
21 views

Two ways to use objects/ vectors [on hold]

I would like to do this with the first example, would doing so be more intensive than the second way? used in both examples ...
3
votes
0answers
35 views

Design of class Location in a World in a universe

A Plane of existence is like a universe in the multiverse. At first, I thought that a Plane will consist of many Worlds, and ...
-2
votes
0answers
21 views

Modifying pointer to object via paramter or return type [on hold]

Say I have the following types defined in my api under a namespace itk: ...
2
votes
1answer
28 views

A trait class to detect whether a template is specialized for a given type

Today's question will just be about a small utility that I needed at some point for one of my projects: a template to detect whether a template is specialized for a given type. The utility uses ...
2
votes
1answer
72 views

Mth to last element

This is a challenge from codeeval Write a program which determines the Mth to the last element in a list. Input sample: The first argument is a path to a file. The file contains the ...
3
votes
0answers
46 views

Quick sort implementations

I made a compendium of different known quick sort partitioning methods, implementations and pivot choosing methods. Any kind of improvements are welcome. Partitioning methods: ...
0
votes
2answers
30 views

Observer pattern implementation

I'm reading Head First Design Patterns and I'm currently reading about the observer pattern. Is what I produced correct? ...
3
votes
0answers
24 views

Optimizing a problem that test all permutations of 1 array with other fixed array

I'm trying to solve this question on a contest programming judge. Description of the problem: There are N birds in a forest, each in their respective tree. There are N tired crows in this forest, ...
3
votes
2answers
66 views

Recognizing a sequence read through OCR software

I am trying to recognize a sentence that I have read through optical character recognition software. This code will eventually run on a Raspberry Pi. I know for certain that it's meant to be one of a ...
0
votes
0answers
18 views

Building up a function call from the function's arguments [on hold]

I'm attempting to write another FFI for Lua in the same vein as boost.python while learning some template metaprogramming c++11 style. I'm attempting to build up a tuple of function arguments from ...
5
votes
2answers
41 views

Basic OpenGL Renderer class

I made this Renderer class recently, to simplify the user interface of my library's API. I would like to ask advice about the move semantics (copy constructor, ...
3
votes
0answers
25 views

C++ PostgreSQL database driver wrapper

I am writing my own wrapper for PostgreSQL (but it can be used for other engines too). I am using this desgin: ...
3
votes
1answer
53 views

Checking for uniqueness within a string

I saw this interview question in the book Cracking the Coding Interview: Implement an algorithm to determine if a string has all unique characters The authors solution uses bit-shifting for a ...
4
votes
2answers
62 views

Thread-safe lock free FIFO queue

A few years ago there was a need to add a FIFO queue between 2 threads into my project. At that time I've got some interesting idea how to do that without any atomics and locks. (There was a ...
5
votes
2answers
71 views

C++ vector that uses expression templates technique to increase performance of mathematical expressions

I've been reading Item 6 from Scott Meyers' Effective Modern C++ and noticed that he mentioned a technique called expression templates. I've decided to give it a try and implemented a vector that ...
0
votes
1answer
27 views

Class and Static practice, IDS and a max instance count [on hold]

I was practicing working with classes and the static property included with them and came up with a simple ID counter and max number list. I also added a quick debug error ...
1
vote
1answer
52 views

Snake class for simple Snake clone

NOTE: I'm only including the snake class (only one file) here because the rest of the code doesn't need reviewing. If you need to see the complete code for whatever reason, it is available on GitHub ...
1
vote
2answers
115 views

A* algorithm in C++

I wanted to know if my A* algorithm is well-implemented and if it could be optimized in any way. ...
2
votes
1answer
37 views

Implementation of Sequence Alignment in C++

Below is my implementation of the dynamic programming solution to the sequence alignment problem in C++11: ...
2
votes
1answer
48 views

Keyboard input class

I am looking for advice on my input component. There is no real problem with it yet, but I am just getting started on everything and want to know if there is any obvious problems with it, plus I was ...
2
votes
1answer
150 views

Ugly_Numbers Challenge

Is it understandable, how can the code be improved? And anything you think that may be helpful. Here is an example of challenge I try to solve. Edit: Thanks for advices how to make better ...
2
votes
1answer
33 views

Truncating Incomplete UTF-8 character

I created a function that truncates an incomplete UTF-8 character at the end of std::string in C++. C++'s Standard Library does not yet support character based ...
0
votes
1answer
75 views

Immutable C++ String class

I have project where I will need to create lots of immutable strings. If I am using std::string, which has huge overhead - about 60-70% against ...
2
votes
1answer
45 views

First Graph Adjacency List

First time implementing a adjacency list. Is the use of exceptions correct? If anyone could test/read the code and give some advice on improvments I would appreciate it. ...
1
vote
1answer
63 views

SPOJ - POWFIB (Fibo and non fibo) Time Limit Exceeds

Problem Find (a^b)%M, where a = Nth non-fibonacci number b = Nth fibonacci number modulo M M = 1000000007 Consider fibonacci series 1,1,2,3,..... INPUT First line ...
3
votes
2answers
40 views

MallocRaii implementation

I'm playing around with RAII a bit lately and I wan't to know if/how I can improve this (quite simple but very helpful) class. A word to two decisions I've made and why: No error handling in ...
11
votes
2answers
117 views

How to speak Brainfuck: for beginners

The following code transforms multi-line input into the the Brainfuck equivalent. One line turns into one program. The resulting programs are split by newlines for readability. Brainf.cpp ...
1
vote
4answers
38 views

Checking whether a graph is bipartite using BFS

I am solving a simple problem that checks whether a graph is two-colourable (bipartite graph). I am using BFS for this approach using C++ STL. I've replaced cin and ...
2
votes
1answer
47 views

Menu class/struct for RPG

I plan to use this menu struct in an RPG played in the terminal. I want to make a RPG similar to D&D. I would like advice on my methods for the menu struct, especially the "hide" and "unhide" ...
3
votes
2answers
152 views

Measure execution time of sorting algorithms

I have to measure execution time of certain sorting algorithms being passed as functions in following program. I also do not have to measure it on random container but also on ascending as well as ...
-2
votes
2answers
78 views

Very basic Tic-Tac-Toe game

This is working C++ code for Tic-Tac-Toe (even not using arrays): ...
4
votes
2answers
45 views

Binary search tree methods

I have implemented a binary search tree with the methods search, insert, and delete. I want to know if this is the best way to code them or if there are any other way by which I can reduce the code ...
1
vote
0answers
13 views

Server framework

I decided to abstract out some of the code I use in personal projects into a library. In particular, it'd be used primarily for server-side programs, but I don't see any reason it wouldn't work fine ...
0
votes
0answers
47 views

Thread function for server-client connection

edit: This section has not thrown segmentation faults so lets focus on it please. I am working on multithreading a data server application. I am new to multithreading in general. I wrote a version a ...
2
votes
0answers
51 views

Tic Tac Toe - NxN

This is a graphical Tic Tac Toe game by using SFML cross-platform library. It seems to work fine. I'm actually new to SFML and making GUIs. If anyone is familiar with SFML, I'd appreciate some ...
4
votes
3answers
126 views

Counting words, letters, average word length, and letter frequency

I'm pretty sure my code is mostly correct. I think I'm having formatting errors more than anything. I keep receiving warnings about "double to float and int to float,possible loss of data. Here is ...
0
votes
0answers
18 views

Makefile: Imporving makefile that uses build directories [closed]

I have a makefile that I've been using to compile my shared libraries which reads in the files from different folders and then builds the objects and binaries in their own folders. The folder ...
5
votes
2answers
109 views

Queue for distributing tasks between threads

I implemented the following class to dispatch std::function<void(void)> objects to a thread pool. Multiple threads will block on the pop call until a task is ...
5
votes
1answer
99 views

Sudoku-solving program

This is a Sudoku solver program which uses backtracking. It is a problem from Online Judge and I made it work after some struggle, but it needs to be faster as I'm getting a Time Limit Exceeded ...
3
votes
1answer
28 views

Draw an ASCII checkerboard

I'm a newcomer to C++, from C#. I wrote a program that prints an ASCII checkerboard with a side length of the number passed to it (link to original Code Golf question). stdafx.h ...
4
votes
1answer
50 views

Attempt on Conway's “Game of Life”

This is my attempt on the Conway's "Game of Life" using C++. The code is functional but I am sure most aspects of the code might have been poorly constructed as I am fairly new at this. Please give ...
3
votes
1answer
72 views

Detecting cycles

This is a challenge question from codeeval.com: Given a sequence, write a program to detect cycles within it. Input sample: Your program should accept as its first argument a path to a ...