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

learn more… | top users | synonyms (1)

1
vote
0answers
12 views

DataStream interface for reading and writing data

I am writing a C++ library which will interact on files, memory buffers and remote files accessible with the HTTP protocol. To handle that, I've decided to create some classes that will use the ...
1
vote
0answers
16 views

Chaining function for range-based for loop

Motivation: I'm relatively new to C++. I'm writing a function meant to be used with range-based for loops. The goal is to be able to iterate over multiple containers at once, each in turn (essentially ...
2
votes
1answer
44 views

Implementing Snap-To-Edge Functionality

Recently I've written some code which implements snap-to-edge functionality for some windows. There is some code duplication as you can see. I think this code can be simpler or possibly improved. ...
0
votes
1answer
31 views

Dictionary file manager

The dictionary class loads entries from a file and then can perform operations on them. The dictionary class then stores the entries back into the file. I would like to know the best way to check if ...
-2
votes
0answers
22 views

C++ - Overloading operator >> [on hold]

I'm implementing my string class. Here is code: ...
3
votes
1answer
58 views

Event-listener implementation

While writing a C++ GUI application more or less from scratch I needed some form of an event-listener system, preferably using lambdas. An event should be able to have multiple listeners and the user ...
2
votes
1answer
43 views

Array of complex numbers

A class Array which contains two data members: a pointer on array of complex numbers and the length of the array. Implement a function for reading the array. The ...
6
votes
2answers
122 views
+50

Binary serialization library

I am currently working on a binary serialization library written in C++11 for a personal project. I'd really like to have a review about my design, my implementation and everything else. The library ...
1
vote
0answers
16 views

SDL - Swept AABB Collision in Pong [on hold]

I've been trying to create a formula for swept AABB with Pong, but I'm not sure what I'm doing wrong. Right now, I'll bounce only when it looks like it's going to collide, but before it's supposed to. ...
3
votes
1answer
60 views

Binary search tree implementation with Rule of Three

I am started to code in C++ and tried 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 ...
1
vote
0answers
51 views

Instance depth ordering system

I have created a template class that manages instances; by order of depth and order of addition (both ascending). It allows for a user to add and remove instances, to retrieve a vector of a layer, ...
1
vote
2answers
59 views

Simple and concise new iterator design [on hold]

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
5answers
87 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
33 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
236 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
16 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
22 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
39 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
35 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
76 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
55 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
35 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
26 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
23 views

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

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
42 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
54 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
64 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
76 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
29 views

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

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
57 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
119 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
41 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
49 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
156 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
36 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
78 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
65 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
119 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
53 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
153 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
81 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 ...