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;
}
好吧,所以我不明白的是,爲什麼你需要*
FunctionTwo?如果你真的想幫我一個忙,有人可以爲我分解代碼(指針部分,因爲我嚴重不明白何時以及爲什麼要使用*
和&
。我不明白關於指針的這一課
+1簡單貓拆解器! – 2012-03-25 00:56:38
你會說......你需要一些指針嗎? – 2012-03-25 00:59:06
http://stackoverflow.com/questions/9636903/what-are-the-distinctions-between-the-various-symbols-etc-combined-with-p/9637342#9637342 – bames53 2012-03-25 01:03:59