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

learn more… | top users | synonyms (1)

6
votes
1answer
47 views

C++ getaddrinfo() wrapper

I'm a C++ novice, but an experienced Python and C programmer. I decided to code a C++ wrapper around getaddrinfo() to get my feet wet (targeted at Unix, ...
-2
votes
0answers
19 views

Is this reverse of binary tree correct? [on hold]

Lets say I have binary tree and want to reverse it. Do you think the following code works fine? ...
0
votes
0answers
24 views

Downloading yahoo finance stock historical data as CSV using C++

This post is a continuation of my previous post where I used jsoncpp package to fetch exchange rates from fixer.io. In this post I have reused the above code and used it to fetch stock historical ...
3
votes
3answers
67 views

C++ Queue Implementation

so I wrote a queue implementation in c++ and even though I know the code probably isn't as robust as it should be and probably doesn't perform all the checks it should, I'd like to know mostly if ...
4
votes
2answers
56 views

A command-line calculator using infix to postfix in C++

I was in the mood for some C++ and decided to write a command line calculator, which understands addition, subtraction, multiplication and parentheses. See what I have: main.cpp ...
2
votes
0answers
17 views

Fetching specific foreign exchange rates from fixer using curl and jsconcpp in C++

I am trying to create my own algorithmic trading system using C++. I have searched the web for a nice tutorial for such systems and I didnt find any. Then I started to learn about ...
0
votes
0answers
23 views

Implementation of circular douby linked list and functions [on hold]

I have some functions I'd like looked over by better eyes. I consider myself a newbie so I was just wondering if you could spot any errors (or potential errors I may have missed) or maybe see ...
4
votes
1answer
32 views

Initializing a std::array from a recursive template computation

I wrote this code for an answer over on SO. I suspect it's possible to clean it up a bit, particularly the base-case specialization for FactorialArray, which is ...
3
votes
1answer
43 views

Evaluating a completely parenthesized arithmetic expression

I tried to solve the following problem in a programming challenge, but the veredict was time limit exceeded. Completely parenthesized expression Write a program that reads a completely ...
2
votes
1answer
32 views

Find offset that minimizes squared difference between two vectors of different size

I am working on a project where the hotspot is some code that is supposed to find an offset, such that the squared differences between a reference vector and a given vector becomes minimal. The core ...
0
votes
0answers
22 views

HackerEarth Prateek and his Friends non-contiguous

How to solve this problem for non-contiguous range? Prateek wants to give a party to his N friends on his birthday, where each friend is numbered from 1 to N. His friends are asking for a gift to ...
3
votes
1answer
30 views

Quicksort using uniform_int_distribution to select the pivot

I have not used C++ for a while. Could you please tell me if my usage of the <random> module is correct? I am not sure if I need to be creating a new instance ...
7
votes
2answers
723 views

Homework to display a square and calculate tips

Here's a simple school assignment I did: Problem 1: Write a program that asks the user for a positive integer no greater than 15. The program should then display a square on the screen using ...
3
votes
0answers
21 views

Get only intended input from user through the console

I finally worked out all of the bugs in this bit of code. I'm pretty proud of it and I wanted to give it to all of you so that you could have it if you wanted it for any console programs that you make....
-3
votes
0answers
14 views

Why does this work on windows and break when I compile on linux? [migrated]

I'm writing a console application for managing and tracking characters, monsters, turn order and conditions applied to make my battle run faster in DnD. The following code works perfectly on windows ...
1
vote
1answer
76 views

C++ Maze Generator

I have made a random maze generator that allows for custom sizes via command arguments. It uses depth-first search and is written is C++. Could you look over my code and suggest any improvements ...
2
votes
3answers
67 views

C++ Tree Class implementation

I am trying to implement a class for the Node of a Tree in C++ in order to represent an HTML structure. It is not complete by a shot, but i'd still like an opinion. TreeNode.h : ...
4
votes
0answers
30 views

cross-platform stdlib-only aligned allocator in C++14

I'm writing a program which uses OpenCL, and the OpenCL types are mostly over-aligned. Sometimes when using stl containers with these types, I'd get segfaults, so I tried to write my own aligned ...
-1
votes
0answers
24 views

c++ program to insert random numbers to a 2D array under a condition [on hold]

I have done a c++ program that inserts random numbers (between 0 and 4) into a 2D array under a constraint that is -Its a array with 5 rows and 9 columns.Therefore total ...
-2
votes
0answers
14 views
4
votes
4answers
624 views

Find Watson's integer

Problem Statement: Watson gives Sherlock an array \$A_1\$, \$A_2\$ ... \$A_N\$. He asks him to find an integer \$M\$ between \$P\$ and \$Q\$ (both inclusive), such that, \$\min \{|A_i-M|, 1 \le i \...
0
votes
0answers
6 views

Qt model and Qml pages/controls binding to that model

We're currently learning Qt Quick (with Qt 5.3 at the moment). QML and Qt are not very familiar to me. I'm looking for feedback on the code below. It's not complete code. Ports.h and Ports.cpp are ...
72
votes
6answers
13k views

Basic Pokedex in C++

I recently started learning C++ about a week ago, and I made a bit of progress. In honor of Pokemon Go releasing, I decided to make a Pokedex with the original 151 Pokemon. So far I have 120 or so of ...
5
votes
2answers
62 views

NamedPoint class using unique_ptr for members

After reading this old article from 2001 I have tried to implement the class from it using unique_pointer. An author's claim is that C++ is not appropriate for ...
3
votes
1answer
37 views

C++ Syncronous Poll Wrapper v2

I recently asked for some feedback on my design for a syncronous wrapper around linux sockets and poll Based on the feedback, I created a new (hopefully more idiomatic) design. socket.h ...
4
votes
2answers
64 views

How can I use vector for entering numbers?

I want to enter names, student numbers and student scores and display this information. I used arrays in this way: ...
3
votes
0answers
24 views

Concurrently identify duplicate files from size ordered list

Following on from my program to identify files that have common file sizes, I have developed an application that takes the output from that process and then compares each of the files that are the ...
1
vote
1answer
58 views

Check if vector of strings has matching brackets

For an online screen, I had a question that would take in a vector of strings, and return a vector of strings indicating whether the input string was a valid combination of ...
0
votes
0answers
14 views

redo the author's table2 using the STL list class [closed]

I am having trouble using the STL list class. When I already used it in a linked list way. table2.h ...
4
votes
3answers
88 views

Program to reverse a string using std::string

Background: I'm trying to learn C++ and I'm doing that by writing some programs by myself. I'm decent with C, but I'm having trouble translating to OOP paradigm. I'm reading from learncpp.com and a ...
0
votes
2answers
56 views

Test if file exist

bool isFileExist(const std::string& fileName) { return !!std::ifstream(fileName.c_str()); } This is a function to check if a file exist. Are there non-...
3
votes
1answer
44 views

C++ Socket syncronous poll wrapper

Below is a simple C++ abstraction over linux sockets, and a layer of abstraction over a synchronous poll call. The goal was to exploit move semantics to allow the ...
2
votes
1answer
67 views

Linked list using dynamic memory [closed]

I created a simple linked list to test what I've learned so far and if I manage everything correctly. If you see syntax errors is't because of copy-paste. I just want to know if i'm making everything ...
6
votes
1answer
57 views

Integer to roman number converter

This is (yet another) integer to Roman numeral converter. To give it a slightly interesting twist, I've implemented this as a num_put facet of a C++ locale, so by ...
7
votes
2answers
118 views

Circular Buffer C++11 Implementation

Here's the implementation of a common data structure I use at work, mainly for logging purposes. I tried to make it C++11-compliant, but even if this standard has been around for a few years, it is ...
2
votes
3answers
68 views

QuickSort C++ Implmentation using Iterators #2

This is part 2 of the previous question asked which is at - QuickSort C++ Implementation using Iterators. Based on Jerry Coffin's answer, I have made the changes except for using templates. ...
-1
votes
1answer
53 views

A Rule of Divisibility by 13

A Rule of Divisibility by 13 When you divide the successive powers of 10 by 13 you get the following remainders of the integer divisions: 1, 10, 9, 12, 3, 4. Then the whole pattern ...
2
votes
3answers
101 views

Linked List design and implementation - C++

Seeking recommendations on how to improve this code, LL always seem to be a struggle. A basic linked list that does include next and previous pointers. I used a struct inside of a class, which I'm ...
2
votes
3answers
150 views

Standard deviation in one pass in C++ - follow-up

(See the previous and initial iteration.) This time, I use tag dispatching in order to make sure that non-random access iterators are not put into a std::distance, ...
0
votes
0answers
37 views

Octree population is too slow

EDIT A few code formatting corrections, can not do it better as I can't get to my working station, editing on my phone I've got basic octree structure for voxel storage. The tree is populated by ...
1
vote
3answers
56 views

Functor to compare two floats with tolerance

What do you think about this implementation of 2 floats comparison functor considering how tolerance is introduced? ...
2
votes
0answers
28 views

Views and ranges for tuple-like objects

This interesting idea came up when I was designing the for_each for tuple-like objects in this post. The for_each in that post ...
7
votes
0answers
73 views

for_each for tuple-likes

I've implemented a C++14 for_each for tuple-like objects. It's similar to std::for_each in that it also returns the functor once ...
6
votes
2answers
186 views

QuickSort C++ Implementation using Iterators

I implemented quicksort using iterators. I am will be grateful, if someone can review my piece of code. BTW, I am just selecting the last element as the pivot (which I plan to randomize later) I am ...
5
votes
2answers
506 views

C++ thread safe log file writer

I made this class (MFC lib) to write a log files. Eventually I want to implement this code in a thread safe way. Log.h ...
7
votes
0answers
65 views

Parse regular expression

Task: This function searches given null terminated string pStr by given subset of regular expression pMatch. Return value is ...
10
votes
7answers
1k views

Generate random binary arrays

I am fairly new to C++ programming and I, so far, love it. I just have been trying to make sure what I am doing is fast, unique, readable, and efficient. Is there anyway I can improve this code, or is ...
1
vote
1answer
42 views

Using a map of shared_ptr instead of single pointers as class members

I'm working on a node.js bindings for libcurl. As libcurl accepts many callback functions as options (like CURLOPT_READFUNCTION for example), I had to store their respective javascript callbacks ...
4
votes
2answers
798 views

Minesweeper C++

This is my improvement of a minesweeper game I took from the internet, which I am quite proud of. Nevertheless I am willing to hear your opinions, suggestions, and comments. ...
6
votes
0answers
100 views

C++ identity function

I've implemented an identity function (well, actually a functor struct) in C++. The goal is that every occurrence of an ...