Site Tools


c_connectlist

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c_connectlist [2013/02/26 16:17] (current)
konovalov created
Line 1: Line 1:
 +  struct myList{ 
 +      int data; 
 +      myList* next; 
 +  }; 
 +   
 +  class MyListClass{ 
 +      myList* first; 
 +  public: 
 +      MyListClass();​ 
 +      void addInt(int);​ 
 +      void showAll();​ 
 +  }; 
 +   
 +  MyListClass::​MyListClass(){ 
 +      first->​next = NULL; 
 +  } 
 +   
 +  void MyListClass::​addInt(int inInt){ 
 +      myList* newList = new myList; 
 +      newList->​data = inInt; 
 +      newList->​next = first; 
 +      first = newList; 
 +  } 
 +   
 +  void MyListClass::​showAll(){ 
 +      myList* current = new myList; 
 +      current = first; 
 +      while(current->​next){ 
 +          cout << current->​data << endl; 
 +          current = current->​next;​ 
 +      } 
 +  } 
 +   
 +  int main(int argc, char** argv){ 
 +      MyListClass iList; 
 +      iList.addInt(34);​ 
 +      iList.addInt(67);​ 
 +      iList.showAll();​
c_connectlist.txt · Last modified: 2013/02/26 16:17 by konovalov

Page Tools