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

learn more… | top users | synonyms (1)

-4
votes
0answers
16 views

Bad argument (response #900 is not integral) in cvPreprocessCategoricalResponses [on hold]

I'm writing a program in opencv and C++: ...
3
votes
3answers
55 views

C++ Dynamic array based stack

This is my first post so if I am doing something wrong in the post please let me know. I have implemented a dynamic array based stack. Can someone point out any pitfalls or things that can be done ...
0
votes
3answers
60 views

Extend number of arguments in std::hypot

I would like to call std::hypot with many arguments (not just 2 or 3). Mandatory requirements: fast run at compile time when possible Non-mandatory ...
0
votes
0answers
19 views

Simple Dictionary opinion C++ [on hold]

Can someone see my code and say if my program's logic is correct and if i can improve something in my way of reading the file in member functions or maybe add more functions to the class. ...
3
votes
2answers
72 views

C++ Graph Class Implementation (adjacency list)

I've got a barebones C++ graph class implemented as an adjacency list. The graph consists of a vector of vertices. Each vertex has a vector of outgoing edges that store the destination vertex id. ...
1
vote
0answers
45 views

Sieve of Eratosthenes implementation in C++

How can I optimize this? ...
3
votes
0answers
23 views

type_list with utilities

The post is follow up to my previous Typelist with extractor. The idea of the code is to provide type list with some handy features. Following is the list of features which are provided, in the order ...
-1
votes
0answers
12 views

Creating a 2D Grid With Command line C++ Putty [on hold]

I am new to coding and was trying to run some example code in my Putty terminal, but ran into a problem when trying to create a 2D grid for this game. It requires command-line arguments, but I'm ...
1
vote
1answer
81 views

A different way to execute a hangman game

Most hangman implementations I have seen keep a list of characters the player has already guessed and compares them to the players current guess each time to see if they have already made the same ...
3
votes
2answers
82 views

Building a simple singly-linked list in C++11

The implementation below works, but I'm wondering if there's a modern C++ alternative. For example: Should I replace the raw new with a braced initializer? ...
0
votes
0answers
31 views

CodeJam Milkshakes attempt [on hold]

I have been practicing code challenges, and came across this one from Google's CodeJam. You can see the requirements here. To solve this, I took the approach of making a vector of maps which ...
4
votes
1answer
39 views

Monitor and video mode querying

I am working on a large project that requires information about the monitor(s). Please don't be confused by the organization of the following structs. The design intent is to be cross-platform, so ...
0
votes
0answers
9 views

Check if cells content is equal [on hold]

I have a matrix of orders ( orders vs k*ordes) and I want to clean/erase the content of the cells that have the same order in both axis.. So, basically I would like to do something like this: ...
2
votes
0answers
16 views

Handling GetTickCount() overflow in timeouts

This is code which must run on XP, so no GetTickCount64, and which should correctly handle the value wrapping around after 49 days. Can it be improved? ...
1
vote
2answers
41 views

Crawling SPOJ through cURL and C++

I am trying to write industry standard code. https://www.quora.com/How-do-I-follow-a-user-on-Spoj-for-solving-problems-Refer-Details Someone gave me this A2A. And I wrote this code for it ...
1
vote
1answer
44 views

Exposing a data member in a class [on hold]

I have a class a which has some methods(geti, seti) which I want to have in all classes b, b1, b2,...b100 I can only think of using a macro right now and it makes debugging a pain, is there a better ...
1
vote
3answers
67 views

C++11 Blocking Queue learning exercise

As part of my own C++11 learning exercise I have implemented this Blocking Queue using the new C++11 thread API. One of the aspects I would like to improve is efficiency i.e. in the ...
2
votes
2answers
93 views

Simple TicTacToe game in C++

I just started learning C++, and this is one of my projects. It's just a simple 2-player (No AI) TicTacToe game that runs from the console. The project was to familiarize myself with arrays, so review ...
3
votes
3answers
84 views

Counting the number of primes in C and C++11

I found this old piece of code that I wrote while I was learning C a while back: ...
1
vote
4answers
301 views

Reading HTML files, removing HTML tags, and writing content and summary to a file

Write a multithreaded C++ application (executable) for Windows Platform. This program uses the two threads to read and process the input data and store it into an output file. Candidate is free ...
-1
votes
0answers
18 views

Link List Memory leaks [closed]

Can someone help me find what is causing the memory leaks in my templated Link list? I'm new to c++ and am struggling to get my head around memory management. My previous language was Java. ...
-1
votes
1answer
53 views

Pointer arithmetic or array

The following is a full example to illustrate my question: ...
5
votes
1answer
90 views

Caches implementation in C++

I had a test task for internship where the main part was in implementing fixed size caches with different displacement policies (LRU/LFU/FIFO). I did that task, but was refused afterwards. Now I am ...
1
vote
0answers
78 views

Snake game in C++ for Windows console

To give you a simple background, I've been programming in C++ for about a week and decided I wanted to build a simple snake game. I made one over the course of a day and this is the end result. What ...
3
votes
2answers
63 views

calloc, malloc, free and realloc wrappers to store the size being allocated

I'm currently building a node.js addon for libcurl. Right now I'm trying to correctly use v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory to ...
1
vote
0answers
21 views

Customized streambuffer for C++ istream

Basically I implement a traditional file-descriptor-based streambuffer for istream operations. The implementation overrides the ...
4
votes
4answers
140 views

Subdividing intervals that contain the largest error values

I'm trying to accomplish the following: Start out with 1 interval on the real line. This interval is processed in some function and out comes an array of errors (size < 10 usually). The maximum ...
3
votes
2answers
368 views

Inorder, Preorder, and Postorder traversal of a binary tree in C++

I am a newbie in this world of data structures and algorithms (returning to these topics after 5 long years). Can someone please check if the code I have written for Binary Tree is OK? Test-case 10, ...
-4
votes
0answers
38 views

Game State Machine and Game States [closed]

For the last few days i have been working on one of my first large game not done in a game engine and i have been struggling to create a acceptable Game State Machine / Game Mode machine call it what ...
0
votes
2answers
38 views

Finding the length of the longest streak of ones in any array

I need help reviewing my code snippet copied below. The below code counts the number of continuous ones in a given array of Size 11. ...
2
votes
2answers
86 views

Recurrent merge sort (without recursion)

For educational purpose I implement recurrent merge sort without recursion. The algorithm idea seems absolutely clear but my implementation appears to be really slow: 5 seconds to sort 10,000 ...
3
votes
0answers
42 views

Largest common subsequence algorithm in C++

I'm relatively new to C++ and am trying to learn good programming practices and habits from the beginning. The code I wrote finds the largest common subsequence between to strings (and output the ...
2
votes
1answer
84 views

Find shortest paths in a matrix using Dijkstra's algorithm

The problem is as follows: I have a matrix with impassable fields those are marked by the input. There is also a castle which reaches up the right side of the matrix. I have to find how many paths can ...
1
vote
1answer
43 views

A variadic tree class that supports multiple types

I'll define template <typename...> class VariadicTree with the following example: ...
3
votes
0answers
48 views

Thread-safe LRU cache for C++

I'm working on a simple LRU cache for C++. There's nothing spectacular or unusual about it, but I would like it to be thread safe. (I'm going to be using this for ...
1
vote
0answers
25 views

Automatic resource allocation for the purpose of resource-dependent task scheduling

Here is what I'm trying to accomplish: Suppose you are trying to control an embedded system with several external hardware resources/components/devices. Naturally, you are concerned with the issue of ...
2
votes
1answer
52 views

Maxflow for baseball elimination game

I have a problem similar to the baseball elimination. Given some teams, the number of wins they have and the number of games they have left between each other I have to find for which team it is still ...
2
votes
1answer
78 views

Finding the two largest three digit numbers missing from a text file

Hear this problem: Write a C/C++ program that reads all the values from the "BAC.TXT" file and determines which are the two largest three digit numbers that are missing from the file using a ...
0
votes
1answer
45 views

Table-Driven Finite State Machine

I'm writing a finite state machine based on a transition table in C++ 14. My code so far looks like: ...
1
vote
1answer
74 views

Reading from text files in C/C++ [closed]

I'm writing a program that has to check which are the two largest three digit numbers that are missing from a text file. I'm writing this in C++ and I'm trying to solve the mystery in a ...
2
votes
1answer
75 views

Auto-resizing array, that accepts negative indexes

I've been coding a helper container template to contain tiles in 2D games. What I figured out I would like when writing code for my games is forgetting all resize stuff, allowing negative indexes (for ...
1
vote
2answers
57 views

Small C++ thread pool

I've made a small thread pool that i'll be using to communicate with a Redis server: ...
2
votes
3answers
79 views

C++ Node class template

I'm working on building understanding of data structures in general, and specifically linked lists in this example. I'm also trying to increase my ability with templates. In cross-referencing dozens ...
0
votes
0answers
29 views

Fast ReadProcessMemory, save guest names that is in memory in hum text file

My code is very slow. How do I get it fast? I would also like to put a scanner on if you have a name in memory to save it in a text file. ...
5
votes
0answers
87 views

An implementation of a static any type

This describes type util::any<std::size_t size, std::size_t align> - an implementation of std::any with a static size/no ...
4
votes
1answer
68 views

Typelist with extractor

The purpose of the code is to store arbitrary number of types. The type can be extracted from it using Extract template, which uses template recursion to get the needed type. There will be compilation ...
1
vote
1answer
49 views

Pipeline with std::thread vectors and queue

here is my code, it works but after few iterations it slows down and stop without any error, I'm looking for a more efficient solution. ...
1
vote
2answers
35 views

SPOJ “TESSER” - Getting TLE using KMP algorithm

The TESSER - Finding the Tesserect problem is tagged as a problem to be solved by Knuth-Morris-Pratt (KMP) algorithm. I'm using KMP, but am still getting time-limit-exceeded. Task Each of T test ...
1
vote
1answer
130 views

Fast Document Distance, C++

This is an attempt at a fast "document distance" implementation in C++. For reference, I found this problem in MIT's OpenCourseware 6.006 algorithms course. A quick look at the ...
6
votes
2answers
116 views

ini file parser in C++

Please review my ini file parser (and potentially some general config file formats). The data structure used is a section, see below. Does that seem a good approach? I was wondering about the name. ...