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

learn more… | top users | synonyms

5
votes
2answers
28 views

Computing the RPY tensor with C++/Eigen (linear algebra)

I'm mostly used to writing scientific code in MATLAB / Python / Julia and my experience with C++ is very limited. I've implemented a fairly simple computation of the Rotne-Prager-Yamakawa tensor in ...
2
votes
1answer
31 views

Improved pointer handle

Please review my improved pointer class. ...
7
votes
3answers
492 views

Testing for “bouncy” numbers

I have a segment of code: ...
4
votes
3answers
312 views

Calculator Improvement

This code works as it is supposed to: ...
3
votes
0answers
26 views

Text-based Tetris game - follow-up - final

Previous question Text-based Tetris game - follow-up 2 Summary of improvements: Removed unnecessary functions print() and ...
11
votes
6answers
884 views

Prime Number Checker

This is my prime number checker in C++. I know that calculating the square root of a number can be very costly, so I don't do it unless the number is larger than 10k, where we would have to check ...
-3
votes
0answers
17 views

Arduino C++ explanation of part of code [on hold]

I am using this code from this link http://playground.arduino.cc/Code/PCD8544 but I do not understand some things and would like someone to help me with. What is happening here on this part of code? ...
5
votes
1answer
63 views

Simple Peg game

I'm new to coding and this code pretty much goes to the extent of my current knowledge I'm looking for ways to improve this code. This code compiles and runs fine in Visual Studio 2013. I'm also using ...
3
votes
2answers
40 views

Custom iterator for a linked list class

I have made a LinkedList class. This is a singly-linked-list and I want to make a forward_iterator for this class without using ...
10
votes
3answers
325 views

Mutable String Class

Here is a String class that I've made for fun in my spare time, for myself. I have a few concerns about it, and am considering going immutable or a mix of the two ...
3
votes
3answers
58 views

Radix sort with C++

At first the input array is traversed and for each number the lsb is found. Then the number is put into appropriate bucket according to it. For example for an input array { 123, 45}, at first 123 will ...
3
votes
2answers
46 views

Basic XML Parser

A while back, I posted an XML Writer. Today I have finished what I hope to be a solid XML parser that, while not professional, will get the job done. To start, I do use a stack on one part of the ...
4
votes
1answer
32 views

Vector implementation

This is a C++ Vector that I've made for the pleasure of it. It was made on a whim and is not related any school assignment or anything alike this. This Vector does ...
5
votes
1answer
39 views

Implement a blocking counter with a reader/writer lock

I'm trying to implement a blocking counter that may have several readers and writers at the same time: ...
2
votes
2answers
222 views

Text-based Tetris game - follow-up 2

The original source code by falgon. For kbhit() and getch() in Linux/UNIX is written by Chris Giese. Previous question: ...
3
votes
0answers
50 views

A Cross-Platform Message Box Library

I recently started work on a game project, and decided to use GLFW for windowing / OpenGL context handling. GLFW doesn't have support for creating message boxes / dialogs, and I was unable to find ...
5
votes
2answers
188 views

Mergesort with std::vector

I made a mergesort implementation based on this code. Please review my C++ version. ...
2
votes
1answer
60 views

Calculate possible balances in piggy-bank by weight

I have solved Piggy-Bank problem on SPOJ using dynamic programming. The question asks you to get the minimum value that is possible with given weight (\$w\$) and one or more coins (\$n\$) with given ...
5
votes
2answers
77 views

C++ game with splash screen and menus

As of now this game only consists of: Splash Screen MainMenu SubMenus Did I apply bad practices, or did I do something well? Is there a better way to do it? ...
-1
votes
0answers
11 views

What am i Missing while trying to create a Menu in a Win32 App(Resource)? [on hold]

I'm trying to learn Win32 using Visual c++ 6.0 (MSVC++ 6.0). I'm learning through this site(winprog.org). I have already created applications with menus, but I left programming many weeks ago. So I ...
5
votes
2answers
85 views

Text-based Tetris game - follow-up

Previous question: Text-based Tetris game I don't have a Linux terminal to be sure whether or not I have implemented the Linux version correctly, but hopefully it's OK. Summary of improvements: ...
6
votes
2answers
91 views

Text-based Tetris game

How can I improve this game? ...
4
votes
1answer
34 views

C++ line editing micro-library

Working on a project, I've taken to adapting the linenoise line editing library for my own use, among other things, rewriting it using C++. The idea is to separate my changes and updates into a new ...
-4
votes
0answers
22 views

BigInteger Multiplication [closed]

Hello All I have been working on a big integer class and I have finished addition and subtraction and I now am currently trying to write a working Multiplication function but if I am multiplying a ...
4
votes
1answer
42 views

Pointer handle with some runtime checking

This is a pointer class of mine that I would like to have reviewed. Right now it only allocates in the stack and has no copy or move operations. ...
1
vote
0answers
52 views

Following the logic of Dijkstra's algorithm [closed]

My code appears to like traveling 2000 miles to a place 200 miles away: ...
2
votes
2answers
92 views

Yet another smart pointer implementation for learning

I based this implementation on CountedPtr in The C++ Standard Library book by Nicolai Josuttis (page 222) and also available online here. I know that I can use the C++11 smart pointers but this is a ...
3
votes
1answer
31 views

Makefile that places object files into an alternate directory (bin/)

I'm trying to learn how to use makefiles, and this is my attempt at making a makefile that compiles source files in a source directory (src/) into object files that are created in a bin directory. ...
3
votes
1answer
61 views

Rotate image 90 degree clockwise recursively

Previous question: Rotate image 90 degree clockwise In this code I have used tail recursive, which is bad. Time complexity is still \$O(N^2)\$, which is worse-case. The only good part is memory ...
4
votes
3answers
114 views

Rotate image 90 degree clockwise

* Time complexity: O(N) * Memory complexity: \$O(1)\$ Is my calculation of complexity correct for this code? ...
4
votes
1answer
62 views

Optimize the Buddhabrot

I am currently working on my own implementation of the Buddhabrot. So far I am using the std::thread-class from C++11 to concurrently work through the following ...
2
votes
1answer
53 views

Code that finds the largest palindrome from two three-digit factors

My code is really ugly, but I don't know how to make it better. ...
7
votes
0answers
68 views

Mapping a textual method name to a function

My program (a daemon hosting a Minecraft server) exposes a D-Bus interface to allow interaction with the server from other processes. To that end, and to avoid a chain of repetitive conditionals in ...
11
votes
2answers
693 views

Optimize simple C++ function to minimize copying

I've been coding C for almost 20 years and figured I should learn C++. As a starting point I wrote the following trivial code to generate the powerset of a set. I'm hoping that some experienced C++ ...
12
votes
1answer
53 views

Parallelization of number factors using OpenMP

For a simple try at parallelization on my own outside of school, I've created a number factors calculator. I hope to eventually come up with something more creative. Since I don't have access to ...
8
votes
1answer
82 views

Rotating and printing an image

I carefully used smart pointer to avoid memory leaks and dangling pointers, but someone says my code has memory leaks. Is it true? If so, how can I fix it? ...
13
votes
6answers
1k views

Guess My Number - computer guesses the user's number

I'm learning C++ right now and one of the activity/tutorial things was to re-write the "High/Low Guess My Number" game - with a twist. I had to re-write it so that the computer had to guess the ...
5
votes
2answers
135 views

Rotate an image (2D array) by 90 degrees recursively with low memory usage

I'm looking for comments on coding style, passing arguments, ...etc. ...
1
vote
0answers
34 views

Counting words in files - follow-up 4

Previous question: Counting words in files - follow-up 2 Continuation of the meta programming template version of counting words. Inspired by example of pirntf ...
8
votes
1answer
225 views

Jarvis's March Convex Hull

I'm more concerned about the coding best practices and how it's written here than the actual algorithm and math. I'm concerned about stack constraints, passing arguments,..etc. If there is anything ...
2
votes
2answers
40 views

Counting words in files - follow-up-3

Previous question: Counting words in files - follow-up 2 For simplifying the code, I have implemented std::regex rather than templates. How can I improve this ...
9
votes
1answer
108 views
+50

Use of Mediator Pattern or Proxy Pattern for a game

When a Wizard casts the Monster Summoning spell, all of the summoned monsters shall follow his command. Should the Wizard interact with his summoned monsters ...
2
votes
0answers
30 views

Counting words in files - follow-up 2

Previous question: Counting words in files - follow-up I have fixed punctuation problems in my previous code by using template, because it is easy to understand and my focus on template mechanism. ...
-5
votes
1answer
43 views

What are the Steps/Algorithm to load/Parse an XML File? [closed]

I want to write an xml parser by my own, i know to search for a string, load files into memory using vectors, but is theres a way i can use this to load and parse xml file, i were told to make a DOM ...
2
votes
1answer
69 views

Counting words in files - follow-up

I have made a non-threaded version of counting words. The result was unexpected the non-threaded version was faster than threaded-parallel version. Non-threaded version: ...
4
votes
1answer
59 views

UVA 10474 - “Where is the marble?”

I have been solving the problem from UVA 10474. In this problem, there will be marbles with numbers written on them. For example suppose five marbles with numbers 50 , 43, 43, 43, 2, 90, 44. There ...
5
votes
4answers
88 views

Project Euler #3 In C++

The question for reference: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? answer: 6857 I'm looking for general feedback as to ...
4
votes
1answer
113 views

Counting words in files

I made a simple program for my study that calculates words in a text files and prints every word and its repeated times in the files. How can I improve this code? ...
9
votes
2answers
1k views

It's almost Friday, right?

This is my final post for my CS1 saga. Mostly all I had to do was just "class-ify" my past project in this post. Here are the requirements: Make all data members private and use constructors, ...
3
votes
2answers
52 views

Magic square functions

I'm writing a program for magic square and I'm a relative beginner to C++ and programming. I was hoping someone could help me find alternate or better ways to implement my code. This is the main ...