Skip to main content
gamedev.net
🔒 Locked

Vector Question

Started by YZRider926 Jul 12, 2006 at 8:22 AM 3 replies 1.2k views
Original Post
YZRider926
YZRider926
I am working on a personal project that calculates grades. I want to use 2 seperate vectors to store the grades, and the maximum score for the grades. I was thinking of creating a base class that would contain all of the functions and variables, and sub classes for each grade type (Howework, Test, Quiz, Lab, Paper, Exam). Each sub class would have the same variables and functions, so I was thinking of just having the base class contain everything. My question is however, when creating the constructors for the sub classes how would I go about intializing the vectors? Also should I initalize them as reference or value types? I realize this may be simple, but Im kinda new to vectors. Also is there a good tutorial anyone knows about for questions like these, I would really like to get more comfortable with the STL and containers. Thanks in advance.
ju2wheels
ju2wheels
I would create a student class (if thats what you are using these grades for) which holds a vector of grades.

Then say you can create an abstract grade class (as you mentioned before) which has a static percentage weight member variable(if its never going to change for a specific grade typ) and a grade member variable.

Each grade type (hw, exam, test) can then inherit this class and specify its percentage weight, and grade.

Then your student class can hold a vector of base Grade objects...

[edit] Vector Reference

SGI Vector Doc
deathkrush
deathkrush
int grade = rand() % 100;

:-)
deathkrushPS3/Xbox360 Graphics Programmer, Mass Media.Completed Projects: Stuntman Ignition (PS3), Saints Row 2 (PS3), Darksiders(PS3, 360)
Zahlman
Zahlman
Quote:
Original post by YZRider926
I am working on a personal project that calculates grades. I want to use 2 seperate vectors to store the grades, and the maximum score for the grades. I was thinking of creating a base class that would contain all of the functions and variables, and sub classes for each grade type (Howework, Test, Quiz, Lab, Paper, Exam). Each sub class would have the same variables and functions, so I was thinking of just having the base class contain everything.


Don't. The key phrase is "contain everything". You won't likely treat the different evaluations polymorphically, either internally (what "behaviour" does a Quiz object have, anyway?) or externally (you don't handle them any differently when you do the averaging: you just have a weight and a grade assigned, and crunch the numbers.

Just indicate the "type of evaluation" as a member of some enumerated type.
YZRider926
YZRider926
Thankyou for all of the responses. Please keep them coming if you have any other ideas.

Thanks.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.