Created
          December 5, 2010 14:18 
        
      - 
      
 - 
        
Save popmentos/729116 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
popmentos revised this gist
Dec 5, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class car :public carcar{ //使用虛擬函數完成此類別 class Benz: public car { //完成此類別 public: Benz(){this->name = "Benz";} void move(){cout << this->name << " in German" << endl;} } ; class Volvo: public car { //完成此類別  - 
        
popmentos created this gist
Dec 5, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ #include <iostream> using namespace std; class carcar{//使用純粹虛擬函數完成此類別 protected: string name; public: virtual void move()=0; }; class car :public carcar{ //使用虛擬函數完成此類別 public: car(){this->name = "car";} virtual void move(){cout << this->name << endl;} } ; class Benz: public car { //完成此類別 public: Benz(){this->name = "Benz";} void move(){cout << this->name << " in Greman" << endl;} } ; class Volvo: public car { //完成此類別 public: Volvo(){this->name = "Volvo";} void move(){cout << this->name << " in Sweden" << endl;} } ; void demo(car c){ c.move(); } void demo(car *c){ //完成此函數 c->move(); } //以下請勿更動 int main(){ car c; Benz b ; Volvo v; cout << "傳入變數" << endl; demo(c); demo(b); demo(v); cout << "傳入指標" << endl; demo(&c); demo(&b); demo(&v); system("pause"); return 0; }