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

learn more… | top users | synonyms

0
votes
0answers
4 views

Djkistra, Kruskal, Prim implementation for adjacency list represented graph

Please review the implementation of Djkistra, Kruskal, Prim algorithms. Points on which I have doubt: My Graph doesn't have any ID for nodes. Nodes are accessed ...
2
votes
2answers
19 views

Stack with a minimum

A practice interview question: How would you design a stack which, in addition to push and pop, also has a function getMin which returns the minimum element? Push, pop and min should all operate ...
0
votes
0answers
14 views

Is using for loops the only method to perform matrix multiplication in C/C++? [on hold]

for (i = 1; i <= x; i++) for (j = 1; j <= z; j++) { c[i][j] = 0; for (k = 1; k <= y; k++) c[i][j] += a[i][k] * b[k][j]; } I ...
2
votes
3answers
244 views

Creating vector of primes using Sieve of Eratosthenes

Please review my Sieve of Eratosthenes implementation. ...
3
votes
1answer
61 views

Tic-Tac-Toe in C++11 - follow-up

This is based on my first Tic-Tac-Toe game: Tic-Tac-Toe game in C++111 i have come up with different game logic for my game. I would like to know which one is more reliable and effective and how to ...
0
votes
0answers
17 views

Merge Sort Variant: Using array link [on hold]

I was looking for the variants of Merge Sort. So my textbook says, A variant of function Merge in which No records need to be moved at all, can be implemented by use of an auxiliary array links. ...
5
votes
3answers
147 views

Small command-line helper tool

I've coded a small command line helper tool for this library I'm working on. The library provides tools for the use of Virtual Texturing on iOS devices (mainly games). This little command line helper ...
5
votes
4answers
252 views

Using std::unique_ptr and std::move

I'm trying out new things (on class Inproc), specifically using std::unique_ptr and ...
6
votes
5answers
307 views

Tic-Tac-Toe game in C++11

I have found Tic-Tac-Toe source code: Tic Tac Toe in C++ I have rewritten the source code in C++11 as shown below. How can I minimize hardcoding in the game logic? ...
-2
votes
0answers
11 views

Tic Tac Toe CMD [on hold]

Im making a command line version of Tick tack Toe for my class yet I keep running into the same problem it keeps stoping after player one take his first turn no player 2 no call back to player one ...
0
votes
1answer
58 views

Octree code performance

I'm using a simple Octree in my program, wanted to know if my implementation could be faster. It is part of this program: https://github.com/Mortis69/rendera Octree.H: ...
-1
votes
0answers
17 views

C++ code problem. Input needed [on hold]

There are several problems with my code: I am trying to create a menu but it goes to infinite loop when a letter or character is put in. It is the same if I used the function ...
2
votes
1answer
42 views

Implementation of a singly linked list

I wonder if the code below is a good (quality and correctness) implementation of a single linked list in C++, in regard of data structure (not the exposed interface). ...
0
votes
0answers
25 views

Treap with implicit keys

I implemented an implicit treap and tested it a little. It works fine but I'd like to know if there are ways to improve/simplify things and/or if some parts are incorrect. Later, I'll augment code to ...
2
votes
2answers
81 views

Superior improved stack implementation using a linked list

Please review my hopefully improved stack implementation As suggested by some answers to my previous code, some of the functions can be overloaded to provide versions of return by value, return by ...
1
vote
2answers
44 views

ostream wrapper for network logging device

I want to be able to write logging data out to a network device with the same ease as using std::cout. So I implemented an ...
11
votes
2answers
96 views

Allowing the user to alphabetize or randomize the contents of a text file

As a newbie programmer, I decided to try my hand at making a program whose function actually might be useful to someone, somewhere. This utility takes a text file, reads it out to the user, displays ...
5
votes
2answers
74 views

Thread-safe Phoenix Singleton class template with Boost

I've implemented the phoenix-singleton as a class template with boost inspired by Modern C++ Design. The code compiles fine with MSVC 2013 - and it seems to work, but I'm new to multi-threaded ...
0
votes
0answers
21 views

Radix sort (LSD) and Counting sort

I'm reading CLRS, and to practice, I rolled my version of radix sort and counting sort. I was looking at some reference implementations, particularly the LSD one from rosetta code, and mine performs ...
1
vote
1answer
31 views

Homogenising iterator and const_iterator

I've reworked (for C++11) a section of PyCXX which contained an almost identical iterator and const_iterator. I would like to ...
4
votes
1answer
27 views

Less insane interface design for a trigger component for T types?

Disclaimer: I just asked this on the regular SE, but was suggested to post it in here since it's kind of a code review. I've recently been playing around with component frameworks, and I'm trying to ...
0
votes
0answers
25 views

returning bool from member variable pointer [closed]

So I'm working with this code that looks like this: ...
5
votes
1answer
71 views

Simple simulated annealing template in C++11

This simulated annealing program tries to look for the status that minimizes the energy value calculated by the energy function. The status class, energy function and next function may be ...
-3
votes
0answers
23 views

Implementing Insertion Sort Using 3 Stacks. (Segmentation Fault - Core Dump) [closed]

I'm getting a Segmentation Fault - Core Dump during runtime. EDIT: Added Input and Output below. ...
7
votes
3answers
111 views

Design a Tips class that calculates the gratuity on a restaurant meal

Design a Tips class that calculates the gratuity on a restaurant meal. Its only class member variable, taxRate, should be set by a one-parameter ...
2
votes
1answer
45 views

Driving 7-segment displays

I made a little JavaScript app here that let people generate bitmap for generating characters. Currently it generate code of a dictionary. But I want to also generate a example that let them play like ...
8
votes
3answers
187 views

Finding shortest paths in directed graphs

I have very little experience in programming with C++ and the following small "program" is the 2nd one I have ever written in that language. I am most interested in comments regarding naming ...
8
votes
1answer
60 views

consecutive_find function for returning a consecutive range of elements

consecutive_find() is a function that returns the beginning of a range that contains strictly N consecutive elements. It was part of a SO question that I answered. ...
0
votes
0answers
28 views

Reading string separated by spaces into vector in C++ [closed]

Heres what my test.txt looks like: 18 19 20 21 22 23 22 23 24 23 24 25 24 25 26 25 26 27 28 29 30 29 30 31 I want to read in the integers in test.txt as strings ...
6
votes
4answers
456 views

Sum of digits in a^b

I'm trying to calculate a problem which requires sum of digits in \$a^b\$, where \$0 \le a \le 9\$ and \$0 \le b \le 4000\$. I have seen various other posts similar to this, but I haven't acquired ...
7
votes
4answers
527 views

Given n numbers, find out the least k numbers from them

I have been solving the following problem: Given n numbers find out the least k numbers from them. For example, if there are 8 numbers like 5,6,3,4,7,8,9,-1. For k = 3 the result will be -1,3,4. ...
0
votes
1answer
39 views

Matrix: Set a row/col to zero

A practice interview question: Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0. ...
1
vote
0answers
40 views

Reader/writer spinlock

I wrote some code for a reader/writer spinlock that gives some preference to writers. Is the code correct? The code uses readerCount for the actual locking and just ...
0
votes
0answers
28 views

Quadratic formula c++ [closed]

Need help on making a code for users to input numbers for a, b, c to find the quadratic formula. ...
0
votes
0answers
33 views
2
votes
1answer
58 views

Multithreading pthread program

My multithreaded version of code works slowly than singlethreaded. Can you help me to understand why? ...
-1
votes
2answers
69 views

Simple auto_ptr [closed]

I wrote my own simple auto_ptr class, but detected some magic. C++ Header file ...
3
votes
1answer
49 views

Virtual Slots Implementation

What I can do to make this code more efficient? It is supposed to be like one of those slot machines where you gamble on it and stuff (like at a casino). ...
2
votes
2answers
74 views

Refactoring observer pattern interface

I have a observer pattern implemented and I'm using two base classes called Subject and Observer. - The ...
5
votes
4answers
539 views

Check if two strings are anagrams

I'm doing some practice questions from the book Cracking the coding interview and wanted to get some people to review my code for bugs and optimizations. Question: Write a method to decide if two ...
2
votes
1answer
43 views

Static to Instance method trampolining with templates

I finally have a working trampoline mechanism. Would anyone care to critique it? Ideone ...
3
votes
2answers
68 views

Speed optimization for transparent gradient blend algorithm

The following algorithm works correctly for the purposes that I need, which is to set the top side of an image with a transparent gradient blend. Any tips to optimize it for speed? ...
5
votes
3answers
79 views

WinInet C++ Wrapper

Because I don't like complex sequences of code for simple functions, I wrote a wrapper for http/https access in A++. Are there any bad programming practices I am using? Is there any functionality I ...
4
votes
0answers
45 views

Sieve of Eratosthenes - segmented to increase speed and range

A lot of the sieve code floating around here and on the 'net is sloppy or broken; in fact, I've yet to see a single one that is correct, clean (in the sense of avoiding superfluous iterations etc.) ...
1
vote
1answer
46 views

Can I get around manually resuming a thread in this C++ thread class?

I have inherited a C++ Win32 thread class which roughly works like this. I am looking for ways to improve the design; specifically I am looking for a way to get rid of the spurious ...
2
votes
3answers
378 views

Improved stack implementation using a linked list

Since my original Stack implementation has lots of bugs that I did not notice, I thought I would recreate and try to improve it. Please review this version. Note ...
3
votes
1answer
55 views

File Output given repeated small operations

I want to write a file which contains values for each cell of a CFD computation. This will be an input file to the program which runs the computation. Currently, the most dubious section of my code ...
4
votes
1answer
57 views

I am porting some C++ standard functions into C# for verification (matching results)

Can you help me look through the functions below to make sure they behave similarly as these standard C++ functions (_fcvt, ...
2
votes
0answers
57 views

Wrap function pointers in template classes

I'm working on a C++ library for Arduino and other embedded systems. https://bitbucket.org/nwehr/kick I'm currently working on wrapping up function pointers and member-function pointers into two C++ ...