All Questions
84 questions
16
votes
4
answers
39k
views
Card and Deck classes
I would like to know whether I'm going in a correct way or not in building my Poker game. So far, I've implemented card and deck classes and I would like to see your feedback about my work. Feel free ...
14
votes
4
answers
94k
views
C++ Student Class
Is this a good approach of designing a class or is there some other way that I am not aware of?
Student.h
specification file
...
13
votes
4
answers
52k
views
Text-based RPG game using classes
I am studying for a degree in "Bachelor of Engineering in Information and Communication Technologies." I am currently on vacation, just after we started learning C++ at the end of the semester. I ...
12
votes
6
answers
1k
views
Class for holding person's information
I have written another program in C++. Excluding the point that the class definition should be in a separate header file, is there anything that needs to be improved?
...
12
votes
2
answers
20k
views
Tree Template Class Implementation for C++
I have not done any parameter checking, however I think the meat of the class is there. Let me know what you think.
...
10
votes
1
answer
928
views
High performance physics simulation - core class design
Below is some stripped down code from a physics simulation. The classes Vector2, Line and ...
9
votes
1
answer
17k
views
Review of 2d Vector class
I'll keep this short. I've never actually done professional C++. I don't really know any of the 'best practices'. I'd like to get some review on a simple class that I've made.
My Vector2d.h file:
<...
8
votes
3
answers
1k
views
Is this Date class well-written?
I'm a C++ beginner and have made a simple class. But I'm not sure if this is well-written. It's basically just a Date class.
...
8
votes
2
answers
1k
views
C-style array class
I often use C API's in C++ that force me to use C-style arrays. I got sick of constantly using a dynamic vector with &vec[0], so I wrote this C-style array ...
8
votes
1
answer
216
views
Simplifying a Resizing Method
I'm making a simple container class for fun and education, but my rebuilding/resizing method seems rather inefficient. Is there an easier way to do this?
...
8
votes
1
answer
4k
views
Creating C++ classes and objects
I'm brand new to programming (in general) and C++ (in particular). I'm learning the basics of classes and objects.
I'm trying to do the following:
Create a class called ...
7
votes
4
answers
3k
views
Testing parity of number of items
This is my first C++ program with classes, and I don't want to develop bad skills. It's very simple and consists of 3 files. This is an exercise from a book, hence the name of the driver file.
...
7
votes
2
answers
5k
views
Use of a static class for a game engine
I've been designing a game engine for the past few months with little issues. However, one main goal with this project is to put it on my portfolio/résumé so naturally I want the code to be as good ...
7
votes
3
answers
209
views
C++ String Class Reimplementation
I started learning C++ about a week ago and I was hoping somebody can critique my code. I decided to implement my own basic String class just for the sake of applying all that I've learned about ...
7
votes
2
answers
6k
views
Playing cards in C++
I am currently learning C++ (note: I am using C++11) and have begun working on a small project to practice what I've been learning. This project is a deck of cards that I hope to use later to create ...
6
votes
3
answers
1k
views
Simple Container Class
I'm learning C++ and trying to create my own container class just for practice (I know about vector, list, map, set). I plan to improve this class and add new methods as I learn new material. Please ...
6
votes
5
answers
2k
views
TString - An implementation of std::string
I wanted to make a feature rich string in C++. Similar to one in python.
I am using C++14.
I have not added much yet, I just want to get my code reviewed to ensure I am going the right way.
Features:
...
6
votes
5
answers
27k
views
Date class in C++
This is a Date class in C++. I didn't use C++ strings because I'm not sure if I'm allowed to. It seems to work fine, but I'm wondering if there are any errors I ...
6
votes
2
answers
2k
views
Simple Multiclass C++ Project
So I'm working through a beginners C++ book and they had this example demonstrating class hierarchy, which was originally in a single file. I tried recreating it with multiple files (header files + ...
6
votes
3
answers
457
views
Deck and Card classes and member-accessing with one header
Previous review of this project:
Card Deck class for a Poker game - version 2
This time, I considered combining both classes into one header file so that I can reduce my use of ...
6
votes
2
answers
8k
views
Basic String class
I wanted to create a basic String class that will hold a CString and have:
constructor, destructor, copy constructor
...
5
votes
2
answers
5k
views
STL-like graph implementation
I have implemented an STL-like graph class. Could someone review it and tell me things that I could add to it?
File graph.hpp
...
5
votes
1
answer
294
views
Multi-dimensional Image Data Structure with Variadic Template Functions in C++
This is a follow-up question for Three dimensional data structure in C++. I am trying to implement multi-dimensional image data structure with variadic template functions. For example, ...
5
votes
2
answers
840
views
Three dimensional data structure in C++
This is a follow-up question for Three dimensional gaussian image generator in C++. Considering the suggestion from G. Sliepen:
Structure of a 3D image
Your 2D ...
5
votes
1
answer
3k
views
chess game Class
Here is the chess class for my very own chess game. Everything is in this class. Generating moves, getting a move from the computer, printing the board etc etc. This is a follow up question to C++ ...
5
votes
2
answers
10k
views
User-defined class for a box
We have just learned about classes. Please help me improve this program. I created a class called Box with members that represent its dimensions. Then I calculate ...
5
votes
1
answer
104
views
Architecture for manager that gets shared among different components
It started with a simple log manager. Then I wanted to implement more features, for example printing the name of the component that send a message. Later on, I can think of giving each component that ...
5
votes
1
answer
463
views
Simplifying member functions in Blackjack game
For my display functions in my Blackjack game, I want to control each player's stats output based on whether a turn is in progress or has ended. Normally, you could only see one card that your ...
5
votes
1
answer
3k
views
Simple Socket class hierarchy
One of the things I wanted to do was make it impossible to forget to initialise or forget to cleanup WSA. Often the network examples will return as soon as an error occurs (say an socket didn't bind) ...
5
votes
1
answer
5k
views
Wrap function pointers in template classes
I'm working on a C++ library for Arduino and other embedded systems.
I'm currently working on wrapping up function pointers and member-function pointers into two C++ template classes (function and ...
4
votes
2
answers
1k
views
Contact management system
I have created a contact management class for practicing, and I want to know your opinion about it.
I know there are a lot of example of contact management class, but I tried to make this one a bit ...
4
votes
3
answers
1k
views
C++ Vector3d class
As part of a physics simulation written in C++ using SFML I needed a vector3d class.
Here is my implementation:
...
4
votes
2
answers
541
views
C++ simple 2D vector
I'm brand new to cpp and tried implementing a simple Vector class that supports abs(), equality and addition operators. I just wanted a quick set of eyes to tell me if I'm doing anything egregious in ...
4
votes
4
answers
6k
views
Tic Tac Toe in C++ with classes
My first language is Python and I learned considerably a good amount of it. So now I started learning C++. I know the basics of C++ and about classes and inheritance.
This is my first serious project ...
4
votes
2
answers
955
views
Console class that handles multiple buffers
I'm working on a 80x25 terminal that splits the screen into two. The top half gets the first buffer, the bottom half gets the second buffer. I'm concerned about readability and accessibility.
For ...
4
votes
1
answer
279
views
C++ Dynamic Array Class Testing
I'm creating a basic Dynamic Array class in C++, and I'd like to know if there are any bugs/memory leaks I haven't noticed yet.
dyn_arr.h :
...
4
votes
1
answer
66
views
Implementing Intersections data structure that is able to hold a container of multiple types that maintains order in C++
I am trying to implement a way to store intersections of rays with arbitrary objects. So far I thought I could make the object derived from an interface and put that as the type in the Intersection ...
4
votes
1
answer
87
views
Terminal based game: Part 3 (Using templated game)
Working from previous posts
In this post: Terminal based game: Part 2 I introduced the concept of a Game object. To build a game like Terminal Base Snake you could ...
4
votes
1
answer
263
views
Nested Deck class design and implementation
Previous review of this project:
Deck and Card classes and member-accessing with one header
I'm nearly finished with my deck of cards project, and this time I made changes to hide the ...
4
votes
3
answers
2k
views
Static class member destruction in C++
I have a basic cache set up. Whenever a user requests a bitmap, it fetches or loads it from disk if it isn't already loaded, significantly reducing load times.
Currently, the design explicitly tells ...
4
votes
3
answers
244
views
Barebones C++ Matrix class
I have implemented a C++ Matrix class using std::vector and a number for rows/cols. The implementation works decently from the QA I've done. I have implemented a Vector class as a derived class but I'...
4
votes
1
answer
507
views
C++ Queue Circular Array Implementation
I'm trying to implement a queue data structure in C++ using a circular array.
Please give recommendations on how I can improve this code.
Also, is my array growth strategy good? I'm doubling the array ...
4
votes
1
answer
571
views
Did I convert this C++ class to Common Lisp correctly?
Here is the original C++ class I converted to Lisp at the very bottom of this post.
...
4
votes
1
answer
706
views
Shader class implementation
I'm trying to design a Shader class. For now, I'm just trying to get basic outline for handling uniforms. Some design goals I aimed for is to avoid passing a ...
4
votes
0
answers
65
views
Creating a C++ style class for storing a data on 2D grid on GPU memory
UPDATED
I would like to create a class, which is intended to represent a field of values on a 2D grid. So, I would like to access the elements with a double square bracket ...
3
votes
4
answers
1k
views
Card Deck class for a Poker game - version 2
This code was first critiqued here (without the Card class): Card Deck class for a Poker game
After learning more about data structures both online and in class, I wanted to revisit my ...
3
votes
2
answers
8k
views
Calculating Julian dates
Refactor this code so that I don't have to insert the parameters any time I need to use one of the functions.
I have a class, say julian, for calculating Julian ...
3
votes
2
answers
5k
views
Validating C++ Time class objects
I created a Time class. Now I want to modify the code to perform input validation. Hour should be between 0-24, minutes and seconds between 0-59. If class need ...
3
votes
3
answers
507
views
Simple class exercise using the "this" pointer
This is my solution for an exercise from a book. It's a simple Golf class with member variables fullname and ...
3
votes
2
answers
779
views
Image loader/writer design (no API, pure C++ on Windows)
I have an image loader, now only for bitmaps. I'm a little confused because I want to split my code to different classes, one for writing a BMP data to a file (WRITER), one for loading BMP data from ...