N
nebulousmenace
Guest
I've got a base class with 2 ints and 3chars in the private section. My Derived classes have a few more ints and some calculated floats. I'm trying to pass the base class privates so that when a derived class is contructed, I can load in values for everything in the constructor. Is this even doable?
Here's the base:
Ex. derived class:
and the main:
Here's the base:
PHP:
class athlete {
protected:
char *firstname;
char *lastname;
char *team;
int jersey;
int gplayed;
Ex. derived class:
PHP:
class bball : public athlete{
private:
int rebounds;
int assists;
int points;
and the main:
PHP:
void main()
{
athlete *ptr;
ptr = new bball("Steve", "Kerr", "Spurs", 25, 50, 5, 10, 5);
ptr->calcFigs();
ptr = new foot("Joe", "Blah", "LameGuys", 1, 12, 500, 500, 2);
ptr->calcFigs();
ptr = new base("Neil", "Garcia", "Marlins", 5, 10, 100, 20, 5, 1, 1);
ptr->calcFigs();
ptr = new judo("Morito", "Ushieba", "Tsunamis", 0, 30, 90, 15, 30);
ptr->calcFigs();
delete ptr;
}