Site Tools


c_connectlist
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();
You could leave a comment if you were logged in.
c_connectlist.txt · Last modified: 2013/02/26 16:17 by konovalov

Page Tools