Quote - (NebulousMenace @ May 21 2003, 01:24)
I'm sorry to keep bugging you guys with this, but I've got a last question.
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? (I don't know what would be helpful, so code is attatched too)
Here's the main to show what I'm trying to do:
[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;
}[/PHP]
btw, you're leaking memory like a sieve...
athlete* ptr;
ptr = new bbal(...);
ptr->calcFigs();
ptr = new foot(...); // LEAK - bbal ha snot been freed!
ptr->calcFigs();
ptr = new base(...); // LEAK - foot has not been freed!
ptr->calcFigs();
ptr = new judo(...); // LEAK - judo has not been freed!
ptr->calcFigs();
delete ptr; // This call only deletes the judo object. You need to put a delete ptr call after each ptr->calcFigs() call.