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

learn more… | top users | synonyms (1)

1
vote
0answers
18 views

Neural net in C++

I wrote a Matrix struct and a neural net that uses it. Why is this slow? Gprof blames Matrix::operator()(int, int) which I ...
2
votes
1answer
33 views

Invocation list implementation (signals/slots)

This class is mostly an educational exercise for me using some C++11 constructs. I wanted to create something similar to an "invocation list" in C#, i.e., a list of zero or more function objects which ...
6
votes
3answers
587 views

Mars rover movement and position

I have written a solution of a Mars Rover problem in C++ using OOP, but I am not fully satisfied with the design. What changes can I make to improve the design? Problem description is: A rover’s ...
-1
votes
1answer
40 views

Basic C++ lin-alg class - conditional jump depends on uninitialized values [on hold]

I am currently working on a small project in C++ to help me learn the language, but I am running into a bit of trouble unfortunately. I have written code for basic vector operations, and I want to ...
2
votes
0answers
23 views

SPOJ GENERAL: sorting by swaps of distance k

I have been trying to solve this simple problem on SPOJ for quite some time now, but I keep on getting TLE (Time limit exceeded) for some reason. Since the problem is in Portuguese, a brief ...
3
votes
3answers
49 views

Place integers into a vector, sum each adjacent pair, refill vector with only the sums of each pair i.e remove all the original data from the vector

Is there a quicker/better way of doing this, mine works great for small vectors but if i get a vector with an arbitrarily large size this would probably take forever to run. Thanks.(P.S. its been a ...
3
votes
1answer
67 views

Counting matrix elements that have “4” or “5” as a neighbor

I have a matrix (500x500) of integers. For each entry, I need to look at its surrounding neighbours (so 8 elements) and determine what the integers are, and run a function on these integers. Here ...
4
votes
2answers
99 views

Find expressions equal to a given number using 15 integers with 4 operators

For example, given 15 integers 70, 75, 32, 4, 64, 98, 73, 52, 36, 88, 96, 58, 79, 39, 75 How can we obtain is 72? 4 operators can be used for the 15 integers to ...
1
vote
1answer
26 views

TCP client library using Winsock WSAEventSelect in C++ - Take 2

This is my second take on creating a tcp client C++ class. The class declaration is general but the implementation is Windows only at this stage and uses the Microsoft Winsock WSAEventSelect model. ...
3
votes
1answer
28 views

Makefile for refactored recursive breadth first search Knight Tour

This is my first hand crafted makefile in quite a while. I thought it might be useful for anyone who wants to review the Knights Tour - Improved Refactored Recursive Breadth First Search. I believe ...
4
votes
2answers
62 views

Mathematical input parser

I made a simple math expressions solver that using a "for" loop iterates over all the characters and stores the numbers and signs in std::vector. It give support for unlimited parentheses and does ...
4
votes
1answer
52 views

Generic singly linked list using the C++11 standard

This here is a templated singly linked list that I have been working on for the past couple of days in C++. I am not a programmer or computer scientist by training; finishing up my undergrad in ...
5
votes
0answers
30 views

Correct and portable serialization

So I've made custom binary streams which work like this: ...
1
vote
1answer
40 views

Spreadsheet key Converter - follow up 2

Based on previous question, The code now is relied on std::regex for validate and split the input. For current improvement, I removed all duplicates functionality ...
4
votes
1answer
76 views

Linked List with c++ class

I am playing with a sort of linked list using C++ classes. I have used a lot of C linked lists (struct based) during C programming course, but there was no behavior. Thus, I am a bit confused about ...
4
votes
3answers
106 views

Producer/consumer problem with four priority levels

Here you can see a mediocre code of mine where I have fun with four deques, each with a different priority. Here is how it works: in a ...
10
votes
2answers
255 views

Identify files within folder structure that have common file sizes

The code takes in two arguments, a path to search and an output file name. It searches the supplied path (including sub directories) and writes out all files that have the same size as any other ...
4
votes
0answers
55 views

ASCII dungeon generator [on hold]

I've written a simple ASCII dungeon generator. It works most of the time, but sometimes it only generates one or two rooms. That's the fault of my self-made algorithm. Do you think I can somehow ...
2
votes
2answers
39 views

Data structure to store large numbers of runtime-dependent arithmetic types

Warning: lots of code. If it's too much, please focus primarly on channel.h and channel.hpp. This is my first time posting on ...
4
votes
0answers
41 views

Knights Tour - Improved Refactored Recursive Breadth First Search for

This development and testing was done on a Dell M6400 Laptop (Intel Core 2 Duo) running Centos 7, g++ compiler, compiler switches -O3 -std=c++0x -D__cplusplus=201103L. (machine bought August 2009 with ...
1
vote
1answer
22 views

Spreadsheets keys converter - follow up

Based on previous question , I have implemented all suggestions. also, i have fixed all unnecessary copies for std::string objects in the code. Is there any thing ...
4
votes
3answers
75 views

Easy-to-use C++ class for asking current time stamp in milli-, micro- and nanoseconds

I have to benchmark my code often, and decided that it is about time to implement an easy API for that: current_time.h: ...
3
votes
1answer
59 views

TicTacToe Implemented with Classes

I made some changes to my class structure and the way I determine a win. I was attempting to decide if it made sense to keep the player completely isolated to TicTacToe game class or if it made sense ...
0
votes
1answer
53 views

Pretify JSON class -followup

This is a follow up to this question. This is an improved version in accordance to comments, suggestions and reviews. Is the namespace implementation proper? is the code readable? I didn't want to ...
2
votes
1answer
46 views

Implementation of a C++ IOC container

I have created a pretty simple IOC container for C++ that should allow me to write less coupled code in the future and make my code easier to unit test. Overall I am fairly happy however I feel like ...
8
votes
3answers
1k views

Prettify JSON class

It's not much, but I tried employing some of the things I learned yet never really got to use, since that kind of code isn't really needed where I work (for the most part). I tried making it as much C+...
3
votes
1answer
34 views

Spreadsheets keys converter

i was trying to solve this problem. as it mentions: In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the ...
3
votes
0answers
41 views

Password & Shadow File Mockup

I tried to implement something similar to linux shadow.txt file and I am not aware of concepts such as memory fingerprinting. Could someone please review this code : ...
2
votes
1answer
62 views

A nonstandard “shared pointer” of sorts

In a few of my projects, I had sort of a common situation, where I wanted to share a pointer to some object, and I want the recipient to be able to check if it is still valid, but I don't want them to ...
6
votes
2answers
94 views

Rectangle-segment collision detection

I am working with C++ and SDL, hoping to create a game later. I am implementing the collision detection between rectangles and segments. I found this (NateS user's solution) about line-rectangle ...
10
votes
1answer
78 views

Sketch of Chutes and Ladders game

The classic Chutes and Ladders game has a grid of 100 squares with various "chutes" (which send a player backwards) and "ladders" (which promote a player forward). The goal here was to randomly ...
5
votes
1answer
112 views

TicTacToe Implementation With Classes

This is my first program using a class that I personally designed. Please pay special attention to the design of the class and I would love pointers and advice on how to better improve logical design ...
4
votes
2answers
89 views
3
votes
1answer
46 views

TCP client library using Winsock WSAEventSelect in C++

One way to write a client which uses a specific protocol, eg http like in this case, is to create a base class with the basic socket handling functionality with virtual functions which can be ...
4
votes
0answers
85 views

Custom hotkey like AutoHotkey

I'm making a hotkey program to aid me using PC faster. By saying hotkey here, I mean any combination of two or more keys in the keyboard. For example, if I press G, hold it then press M I have hotkey ...
7
votes
2answers
88 views

Formatting seconds as hours:minutes:seconds

This is basically my school homework and I want to know what to improve, and what not to do. The homework basically is this: You will get a input in seconds, which is supposed to be shown as H:MM:SS ...
-4
votes
1answer
141 views

C-type classes in C++

I have written some improved C-type classes in C++ and wondered whether these are suitable for professional use or in which way they would have to be improved to be professional or more powerful. ...
2
votes
1answer
70 views

Simple Contains() Function

I wrote simple generic function to check if any STL container has an element. It seems work fine. I have tested it with VC++, GCC and Clang compilers. It works perfectly. How can I improve it further....
4
votes
2answers
76 views

C++ object pool

I am a beginner and would like to build a pool. I made some research and found out that if my software has heavy object create and delete part, I should use a pool because of performance. I made some ...
1
vote
1answer
74 views

A multi-class, multi-racial RPG with magical combat [closed]

This is my first attempt at making a program in C++, I was wondering if my code was good or should it be improved upon. Here is the code below. Any help debugging would be greatly appreciated. Some ...
3
votes
3answers
96 views

Find All the Primes Between two Numbers

I wrote a solution to the Coding Challenge SPOJ Prime in C++ using the Sieve of Eratosthenes. How much Ever I tried I could not get over the Time Limit on SPOJ which is 6s for Primes upto 1000000000. ...
2
votes
2answers
38 views

GUID Generation and Invalidation

I'm updating an old ECS I wrote a couple years back, and I've written the following piece of code in order to generate a GUID: ...
2
votes
1answer
81 views

Pointer lists for a C++ garbage collector

The problem My intention is to have a class A and class B. class B has a ...
1
vote
0answers
36 views

Graph (adjacency list) and DFS (topological sort)

The vertices on the graph are numbers from 0 to |V| - 1 for convenience. I was thinking later to use a template wrapper for the graph. Graph.h: ...
6
votes
1answer
100 views

Conway's game of life in C++ with SDL

This is my attempt at a basic implementation of GOL. The user can add and remove cells with the mouse and some basic stats are printed to console. Any feedback is welcome, but I have a couple of ...
-2
votes
0answers
21 views

Advantage of make QShortcut pointer as class variable

I have following code. Header file is myView.moc.h and c++ file myView.cc ...
2
votes
3answers
91 views

Non-Sieve Prime Number generator

...
-1
votes
0answers
25 views

Algorithm to draw the shortest path in grid

I want to find the shortest path between two points in the grid, and than mark the path with '+' sign. I found the shortest path using BFS algorithm, but now I'm not sure how can I mark it using ...