| 发表于:2007-08-24 14:23:48 楼主 |
#include <iostream> using namespace std; class simplecat { public: simplecat (); // constructor simplecat(simplecat&); // copy constructor ~simplecat(); // destructor }; simplecat::simplecat() { cout < < "simple cat constructor... " < < endl; } simplecat::simplecat(simplecat&) { cout < < "simple cat copy constructor... " < < endl; } simplecat::~simplecat() { cout < < "simple cat destructor... " < < endl; } simplecat functionone (simplecat thecat); simplecat* functiontwo (simplecat *thecat); int main() { cout < < "making a cat... " < < endl; simplecat frisky; cout < < "calling functionone... " < < endl; functionone(frisky); cout < < "calling functiontwo... " < < endl; functiontwo(&frisky); return 0; } // functionone, passes by value simplecat functionone(simplecat thecat) { cout < < "function one. returning... " < < endl; return thecat; } // functiontwo, passes by reference simplecat* functiontwo (simplecat *thecat) { cout < < "function two. returning... " < < endl; return thecat; } 针对上面的问题,小弟有以下几个疑问: 1, simplecat(simplecat&);这个该如何理解 2,simplecat functionone (simplecat thecat);这里面的参数又该如何理解 3,simplecat* functiontwo (simplecat *thecat);这又是什么新的意思 前面的例子都蛮简单,但到这里是一头雾水.请能者给个详细的解释. |
|
|
|
|