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

learn more… | top users | synonyms

3
votes
1answer
44 views

Simple Linked List that holds an int

I am inexperienced in C++. I was able to get my LinkedList to be fully functional. I was hoping to get some feedback as to whether or not I followed bad practices ...
-2
votes
0answers
9 views

C++ operator precedence [on hold]

I have the following code in my main() function: float x = 1; (x + 1 < x + 1 * 4 / 3) ? cout << "True\n" : cout << "False\n"; Isn't that the same ...
3
votes
0answers
22 views

C++ vector implementation errors

I haven't really programmed in C++ for about a year, and realised that I should get back into it, and tried my abilities out by remaking the STD vector class. However, my C++ is a bit rusty at the ...
0
votes
0answers
14 views

Frequent subgraph mining using the Boost library

I'm trying to make a programme that read graphs from .txt file and then create and put them in a vector. How can I make it faster? ...
2
votes
0answers
28 views

SImple wrapper for OpenGL

I am writing a simple wrapper for OpenGL for personal use. Currently I have a gl::Buffer (for VBO, EBO etc...) and it can have several types (...
1
vote
0answers
22 views

HDD Based AVL Tree

For class I have to write a program that reads (plaintext) numbers from a file, and inserts them into an AVL tree stored in another (binary) file. I cannot have more than about 10 nodes in memory at ...
6
votes
1answer
42 views

Fixed-size block allocator

I have written a fixed-size block allocator implementation and would like some feedback as to what I could improve in my code and coding practices. Your comments or notes are welcomed! An auxiliary ...
2
votes
0answers
19 views

Storage policies

I often come across situations where a library component needs to buffer a large amount of data for later processing. The problem is that at the design stage a choice needs to be made as to whether to ...
6
votes
2answers
322 views

C++ Linked List Implementation

I'm learning C++ and also about data structures, so I am trying to implement some. This is my linked list. I've included two different ways of getting the length of the list, with a ...
0
votes
0answers
42 views

c++ switch statement help pizza order. [on hold]

Im having trouble with the code running. I am pretty new to this since you can tell that its a simple problem and this is for my intro class. I must use the switch statement to calculate the bill for ...
0
votes
1answer
69 views

const_cast of std::mutex in 'get' member

Look particularly at the const_cast in the member getValue(void). Any comments? It seems the best solution me. ...
11
votes
2answers
96 views

Toy virtual machine

I am a web developer, trying to have fun with C++11, so any positive/negative feedback is very welcome. This is a toy virtual machine with 3 registers and 3 commands: vm/vm.h ...
0
votes
0answers
13 views

Program to break apart an int and determine how many even, odd, and zero digits [on hold]

I'm trying to write a function that breaks apart an integer and outputs the count of even, odd, and zero digits. I'm having trouble with the do...while loop. It seems to be an infinite loop. I thought ...
7
votes
2answers
66 views

Type-safe cartesian co-ordinates

I've recently been fiddling around with a type safe implementation of cartesian co-ordinates (and a few operations on those co-ordinates). Often it's easy to get units mixed up: is something in ...
3
votes
1answer
35 views

Depth First Search and Breadth First Search in C++

I am trying to learn DFS and BFS. However, I just want to make sure that I am not doing anything wrong. Would you please determine if the BFS and DFS functions are correct? ...
0
votes
0answers
23 views

Calculating the determinant of a matrix [closed]

I am working on a project that I needed to calculate the Determinant of a matrix. Usually, I would just have a class "Determinant" and just calculate that way, but, things have changed and I have had ...
4
votes
4answers
100 views

Extremely simple character manipulation

Given a string, this code Multiplies odd numbers Subtracts even numbers, do nothing if only one even number is found Turns uppercase letters to lowercase and vice versa I think this code is too ...
0
votes
0answers
15 views

Working with C++'s Queues [closed]

So, to teach myself how to work with queues in C++, I started out simple. All I want to do is find the greatest value contained within a queue of integers. When I did this: ...
1
vote
1answer
61 views

Constructing a UI to ask a list of questions

This code fragment from 2009: ...
5
votes
1answer
83 views

Particle class for physics simulation

This is a very lengthy class called Particle, it relies on two other headers, one of them is a simple struct which contains an x and y (...
5
votes
2answers
132 views

“Set” your expectations low for this ADT

For my third assignment in CS2, I was given the following: A set is a special bag that does not allow duplicates. Specify each operation for a set of objects by stating its purpose, by ...
2
votes
1answer
56 views

Palindrome Checker with Stack

In my answer to this question, I wrote a new solution. Personally, I would not use a stack, but given that a stack was required, how good is this solution? In this solution, I add half of the word, ...
2
votes
4answers
65 views

Palindromes with stacks

I'm creating a simple function to verify whether or not a string is a palindrome, and must use stacks in solving it. ...
3
votes
3answers
44 views

Speeding up create CRC function

I have a function like this: ...
2
votes
0answers
51 views

Efficient compile-time directed graph

During my research in Rigid Body Dynamics, (where Contact Graphs are used to solve the contact problem) I came across the question if it is possible to define at compile time a directed graph (class) ...
4
votes
3answers
242 views

Gas cost calculator

I am refreshing my university knowledge on C++ due to a job interview and I am trying to understand everything in depth. Is there any reason for me to use pointers and dynamic memory features of C++ ...
-1
votes
0answers
13 views

Program crashes while freeing dynamically allocated memory [closed]

I'm representing a graph using an adjacency list here. Here is the code: ...
-2
votes
0answers
20 views

Comparing two values to two other values efficiently [closed]

So for an important piece in my code (thats getting called a lot) I need to compare 2 doubles (a and b) to 2 other doubles (x and y) to meet the following conditions: return false if both a and b ...
4
votes
2answers
75 views

String Token Generator for ExpressGenGen

StringTokenGenerator is an interface (or abstract class) I've created to the specific task of generating a string token of a given character set. It allows ...
4
votes
1answer
52 views

Prime number calculator using Sieve of Eratosthenes

I've been writing this prime number calculator, and I've gotten it pretty quick in comparison to most I've seen knocking about. This one uses the Sieve of Eratosthenes approach, and I've optimised the ...
0
votes
2answers
39 views

Uva Online Judge problem 100, 3n + 1

I am having a tough time submitting this code to UVa Online judge and having it pass. I keep getting the message - Your program used more CPU time than what is allowed for this problem. That means ...
2
votes
0answers
40 views

Multi Server Architecture: ASIO C++

I am working on an application where the user will have flexibility to create and destroy a server instance at any port he/she wishes. User can create multi servers operating simultaneously - each ...
4
votes
1answer
70 views

Conway's Game of Life simulation

I went ahead and quickly typed this up and am unsure on how to improve. How could this be optimized? Note: there are some functions from a custom library here that do exactly what they sound like they ...
1
vote
0answers
24 views

There is too much logic to track if file was converted or not [closed]

In the code below, I want to set icon in listview as red or green based on if file was converted or not. The code below is ugly to say the least. If both files are converted, I want to set the icon to ...
9
votes
2answers
114 views

Solving a Binary Puzzle

A while ago I started solving Binary Puzzles. Not having done much C++ in my life, although it feels like I have a pretty good understanding of C++ in general, I figured it was time to do some C++! ...
3
votes
0answers
64 views

Magic square and backtracking

I have to write a program that solves a NxN Magic Square, with digits from 1 to N2. What do you think? ...
5
votes
1answer
82 views

Minimum number of coins - (dynamic programming solution - topdown approach)

This is a problem from topcoder tutorials Given a list of N coins, their values (V1, V2, ... , VN), and the total sum S. Find the minimum number of coins the sum of which is S (we can use as many ...
3
votes
1answer
56 views

Reading from a CSV file in C++

I wrote this code to read from a CSV text file (containing data such as 12,3,568,48,3,8 with no more than 3 digits to each number). It stores the numbers as char arrays in the vector ...
4
votes
0answers
37 views

Macro to build type declaration

This is some macros to help build a traits class (For the parser/printer classes I am building). Traits.h ...
3
votes
1answer
32 views

Serialization: Step 2 YAML Parser

After this question, the next part. Coding to the same interface as the previous question: Note: Since not every system has libyaml installed, the config script tries to detect its existance and ...
1
vote
5answers
47 views

CCC Rövarspråket (Pig Latin) translator

I have a challenge: In Sweden, there is a simple child's game similar to Pig Latin called Rövarspråket (Robbers Language). In the CCC version of Rövarspråket, every consonant is replaced by ...
2
votes
0answers
40 views

Simulating a linear linked list using an array

A program to simulate a linear linked list using an array: Specs: A y : Create a new node with data value y, and append this node to L I x y : Find the node t with value x, create a new ...
7
votes
2answers
220 views

Printing/Saving a Payroll Chart

This code was inspired by this question: Payroll Program. I saw lots of ways I thought the code could be improved. So much so that I thought it wouldn't be particularly constructive to post all of ...
2
votes
0answers
25 views

Mediator class to handle a bunch of rules between objects

When a LivingBeing attacks another LivingBeing, an attack roll is made to determine if a hit occurs. If a hit occurs, a damage ...
2
votes
0answers
59 views

Using static storage for ECS framework

I have just recently completed an ECS framework that I've been working for some time. It's supposed to provide easy use of ECS architecture concepts with as little syntax as possible. The framework ...
8
votes
3answers
595 views

Payroll program

I wrote a program that calculates gross wages for employees. The program asks the user enter an employee's ID, hours worked and hourly pay rate. It then calculate the gross wage for that employee and ...
4
votes
1answer
78 views

SFML Ping Pong improved (V0.3)

Some of you may have seen my previous post asking if my code was efficient and easy to read. I have made some more improvements to it by adding sounds, visual count down and checking if the window ...
1
vote
0answers
34 views

Template based return type from object and class method

I'm looking for a better implementation of this. The current solution looks bad to me and breaks the VC10 compiler if you call Create() with a method expecting two ...
5
votes
4answers
145 views

Mathematical matrices implementation

As a Java programmer who's trying his hand at C++, I thought I'd start building a library for working with matrices as my first C++ project. I've got very little C++ experience and it's been a long ...