Tagged Questions

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

learn more… | top users | synonyms

9
votes
0answers
62 views

Ultimate Tic-Tac-Toe with AI and GUI

During my hiatus, I decided to revisit some of the Tic-Tac-Toe questions here. I created a simple Tic-Tac-Toe GUI game, and then thought, might as well do the Ultimate Tic-Tac-Toe challenge. I am ...
2
votes
4answers
204 views

Calculate employee wage

This is for a class assignment. The objective is to write a program that will take in user input for employee information and print the wage based on hours worked. Please review my code. ...
3
votes
1answer
32 views

An owned file descriptor

File descriptors are a common resource in Unix and Unix-like operating systems. They're a way to represent a resource such as a file, socket and so on. The user should release a file descriptor as ...
7
votes
2answers
232 views

Custom matrix class

It took me while to finish, but here is my custom matrix class. I assume that the row/column iterators are the most critical part of this class but anyway I would very much appreciate your ideas of ...
2
votes
3answers
63 views

Is usage of friend class appropriate in this case?

I want to have a class that stores data from an input file, for use in a simulation program. It is like a struct but may require some small functions for accessors. A seperate class reads all the ...
-1
votes
0answers
42 views

how to only allow 3 values in a “if” and “while” statement to allow the loop to exit [on hold]

I'm just stuck on some logic statements. specifically the ones that are in the function char GetInteger() so how would I only allow 3 values to cause the loop to ...
0
votes
0answers
13 views

How to fix/optimize this calendar program? [Using Zeller's Congruence] [on hold]

I have this calendar program that I've finished but it's kind of long. Also, could someone tell me why I'm getting the wrong starting days even though I'm following a formula? Thanks. ...
4
votes
1answer
27 views

Get extension(s) from path

I'm writing an utility function that returns the extension(s) of a boost::filesystem::path (v3). Boost's path class already has some of this functionality ...
5
votes
0answers
31 views

Easy bitset IO v2

In a previous question I posted a method for easy std::bitset IO on a bit-for-bit basis. This question was later followed up in another solution. Both of these ...
4
votes
0answers
30 views

A reversed-string Trie data structure

This is a simple Trie data structure for strings, except it puts the strings into the structure backwards. The insert method simply iterates over chars from the string-to-be-inserted backwards, and ...
3
votes
0answers
30 views

Grayscale bilinear patch extraction - SSE optimization

My program makes an intensive use of small sub-images extracted using bilinear interpolation from larger grayscale images (some call this problem subpixel translation). I am using the following c++ ...
4
votes
2answers
41 views

Threaded generalised transform

I'm writing an application which works with huge amounts of sequential data, and often found the need to use std::transform. I see two potential improvements to ...
-1
votes
0answers
19 views

Implementing template map class [on hold]

I am creating a netflix-type program and I already have a map class with the form template <(class keyType, class valueType)> class Map I need to create a movie class and I think the movie title ...
7
votes
2answers
83 views

Sockets and networking for a multi-platform game

I'm in the process of adding network support for a little Mac & Windows game I'm writing. Today I've finished the basic sockets plus a few other network helpers and would appreciate having the ...
4
votes
2answers
73 views

Inserting and displaying books

I'm trying to write a program where you can insert and display some books (without using a database). For doing this, I use three classes: Book - is the base ...
2
votes
2answers
65 views

Skipping whitespaces when reading file

In reading a file, I found blank lines (even at the bottom) crash the program. To fix this, I've added the following if statement: ...
4
votes
2answers
79 views

Creating a better BST

I have created a BST like many others. I am curious to if there is a better way to write it. It seems pretty straight forward, but I feel like it can be improved on a bit. ...
6
votes
2answers
120 views

Limited memory priority queue

I'm trying to implement a highly efficient limited memory priority queue. The interface is the same as a std::priority_queue. Can anyone suggest any performance ...
3
votes
1answer
363 views

Vehicle-crossing simulation

It seems like this code should be shorter, but with all the error checking it is long and hard to follow. This is for a simulation of vehicles crossing a bridge, and this part is dealing with mutexes. ...
1
vote
0answers
43 views

Enum list to STL container, part 2

Original question: Enum list to STL container Goal: Write a function enumToSTLContainer() that is to return any STL container whose elements are from a specified ...
6
votes
2answers
142 views

BFS shortest path program

The task was to find the shortest path between P and K in a maze. You can move horizontally and vertically, where # is a wall and ...
2
votes
1answer
46 views

Enum list to STL container

Can someone improve upon this function of mine? EnumToSTLContainer is supposed to make a copy of any STL container whose elements are from a specified ...
4
votes
1answer
52 views

Adjacency-list graph implementation in C++ (redone from scratch)

I had posted here before, but I decided that the approach used earlier - where every Vertex stores a vector of pointers to ...
3
votes
1answer
85 views

Public interface for nearest neighbor data structures

I am making a small library of metric data structures. That is data structures, which associate points in the n-dimensional space with objects and allow the user to find objects which are closest to a ...
1
vote
2answers
82 views

Count all unique subsets with Sum S

Team 7 faces a horrible foe. He can only be defeated with a special quadruple combination attack of strength (\$1 <=S <= 10^9\$). Naruto, Sasuke, Sakura and Kakashi must attack ...
4
votes
0answers
30 views

Mostly portable 128 by 64 bit division

I wrote this out of curiosity. It is based on the theory behind Knuth's Algorithm D, and intended to emulate the behavior of the x86 div instruction (though the ...
8
votes
1answer
176 views

Dictionary (with silly hash)

Based on this question (but fixed so it can run). I have kept the code as close to the original as possible. I have Marked all the changes with Loki (should be easy to spot). Code here is written in ...
5
votes
1answer
49 views

Collision-detection for an SDL game

I am working on a simple SDL game in C++. I want to make my collision detection implementation better. Here's the complete project: ...
7
votes
3answers
463 views

“Silly program” for moving the mouse and doing other things

I've made a simple program that moves the mouse and do other silly stuff. I want you to look at it and tell me what can I do better/less space and also what can I add. I want to prank my friends. ...
10
votes
2answers
121 views
+100

Refactoring image loading/manipulation class

I have this Image class that I've been using for some time now on personal projects and games I eventually write. It was written in C++98 style and it is starting ...
7
votes
0answers
40 views

Wrapping types with alignment requirements

Visual Studio 2013 still doesn't support the alignas keyword in C++11. This causes some problems with alignment of types in various situations. Thankfully the ...
10
votes
5answers
3k views

while(user == gullible)

The goal for this project was to: Write a program that continues to asks the user to enter any number other than 5 until the user enters the number 5. Then tell the user "Hey! you weren't ...
-3
votes
0answers
56 views

Hashing function and Dictionary [closed]

I have been trying to fully implement my hashing table, but I don't really understand exactly how the code works. I have my header file setup fine, I am just missing implementing the following: ...
1
vote
0answers
33 views

C++ makefile for CPLEX with environment loading

CPLEX is a solver for mathematical problems made by IBM, and it offers callable C libraries. My usual project configuration is a main.cpp file will all the important code and a simple cpxmacro.h file ...
2
votes
3answers
69 views

Reading input from file for bridge simulation program

I am simulating a bridge where only one car can cross at a time. The bridge runs north south. The car arrival times and times taken to cross the bridge are given in an input file. The format is ...
4
votes
1answer
60 views

Test with array and mock

Here is my function I want to test: ...
2
votes
0answers
51 views

GOF Composite Design Pattern Implementation Using Modern C++

After reading about the composite pattern from the GOF design pattern book, I thought to re-implement the code mentioned in the motivation section using the modern C++ concept/idioms. Below is the ...
0
votes
0answers
18 views

Rendering speed in SDL2 [closed]

I have a large rendering class using SDL2: video.cpp (github mirror) It all works fine, except it's a bit slow (starts lagging at larger resolutions). The reason for this is obvious - it basically ...
6
votes
4answers
763 views

String case reverse function in C++

This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Let's get critical here. ...
14
votes
3answers
3k views

Is it Friday yet?

This is the first program that I have written in my C++ saga that I actually think is useful. The description for this assignment is kinda long and mundane though: Write a program that inputs a ...
9
votes
2answers
207 views

Implementation of fixed size hash map

I'm trying to brush up on my algorithms and data structures and wrote a fixed sized hash map assuming both key and value will be only integers. This is a significant simplification of the real case ...
7
votes
2answers
147 views

Linked list implementation of a stack

I am working on a basic linked list implementation of a stack of ItemType (currently set to double but can be changed) values. The stack code will then be used in a ...
3
votes
1answer
87 views

XML Writer in C++ - Updated

I recently posted about a basic XML writer in C++ and got a lot of great feedback. Well, I'm back with an updated version of the XML writer that is a bit less basic, but hope it's better than the ...
-3
votes
0answers
49 views

I can't make my code functional. [closed]

These are the errors I am getting. I googled them and I went through my code and don't see what I need to fix. ...
13
votes
4answers
397 views

Array alive/dead entity “refresh” algorithm

I have an Entity class that can be either dead or alive. I store entities contiguously in a resizable array. During an ...
3
votes
3answers
111 views

Chain of Responsibility Design pattern in C++

I am learning design patterns from Design pattern for dummies. From that book I have written a chain of responsibility pattern with two programs. Can someone review and let me know which one is proper ...
6
votes
2answers
272 views

Course Grade Calculator

Here is my objective: Ask how many categories there are for the class (ex: Labs, Tests, Homework, Quizzes), and then ask what total percentage each make up for the class (ex: Lab are 15%, tests are ...
0
votes
0answers
7 views

why is the private member function accessible outside the class [migrated]

I expect he below code to give an error but Compiles ok ...
10
votes
7answers
2k views

Cola Machine #1

I have been working on the code listed here. I am working on Problem #2, 0 stars. Here's what I have to do: Write a program that presents the user w/ a choice of your 5 favorite beverages (Coke, ...
6
votes
0answers
76 views

Easy Bit IO. Very simple interface works up to N == 64

After reading this question Easy bitset I/O. I wanted to see if there was a simpler way of doing it. This is how I would define a way of outputting ...