With apologies to you guys, Jessie Liberty and Robert Lafore here is some
code I'm mutilating in order to learn CLASS:
// SEE TWO MESSAGES BETWEEN STARLINES BELOW
#include
#include
class Humanoid // declare a class
{
public: // visible anywhere in program
int GetAge(); // public function
void SetAge(int Age); // public function
void Philosopher(); // public function
private: // accessible ONLY within the class Humanoid
int She_He_Its_Age; //member variable
};
int Humanoid ::GetAge() // return value of this private member
{ // of the class
return She_He_Its_Age;
}
void Humanoid::SetAge(int Age) //define SetAge
{
She_He_Its_Age = Age; // Set the age of the humanoid
}
void Humanoid::Philosopher() // member function to define the
{ // humanoid by what he says
cprintf("Why is their something and not nothing?.");
}
int main()
{
Humanoid Frank; //instantiate Johnny as name-like object
Frank.SetAge(65); //call member function to set the age
Frank.Philosopher(); //call member function for characteristic of
// a philosopher
clrscr();
gotoxy(10,5);
textcolor(11);
cprintf("Frank HAS to be frank because that's his middle name.");
gotoxy(10,6);
cprintf("Frank is a humanoid who is ");
gotoxy(10,7);
//***********************************************************************
//THIS NEXT LINE - HOW DO I GET COLOR IN ENTIRE LINE?
//**********************************************************************
cout << Frank.GetAge() << " years old.\n";
gotoxy(10,8);
cprintf("and he goes around all the time saying things like " );
gotoxy(10,9);
//***********************************************************************
//AND IN THIS ONE BELOW
//***********************************************************************
Frank.Philosopher();
return 0;
}
--------------------------------END HERE---------------------------
Sincerely,
Frank
--- PPoint 2.03
---------------
* Origin: Maybe in 5,000 years - frankmas@juno.com (1:396/45.12)
|