class SimpleCat
{
public:
SimpleCat();
SimpleCat(SimpleCat&);
~SimpleCat();
};
SimpleCat::SimpleCat()
{
cout << "Simple Cat Constructor.. \n";
}
SimpleCat::SimpleCat(SimpleCat&)
{
cout << "Simple Cat Copy Constructor ..\n";
}
SimpleCat::~SimpleCat()
{
cout << "Simple Cat Destructor! ... \n";
}
SimpleCat *FunctionTwo(SimpleCat *theCat);
void main()
{
cout << "Making a cat ...\n";
SimpleCat Frisky;
cout << "Calling FunctionTwo ..\n";
FunctionTwo(&Frisky);
system("pause");
}
SimpleCat *FunctionTwo (SimpleCat *theCat)
{
cout << "FunctionTwo, Returning... \n";
return theCat;
}
Ok, so what i don't understand is, why do you need the *
for FunctionTwo? If you really want to do me a favor, can someone please break down the code for me (the pointer part, because i seriously don't understand when and why to use the *
and &
.