c++ - GNU GCC compilor error "multiple definition of main" -
c++ - GNU GCC compilor error "multiple definition of main" -
i new ubuntu, need develop assignment in c++. using codeblocks ide write c++ programs. whenever compile in it, gives these errors:
multiple definition of main warning: command reaches end of non-void function
here code want compile now:
#include <iostream> #include <stdlib.h> using namespace std; /* node class */ class node { public: int get() { homecoming object; }; void set(int object) { this->object = object; }; node * getnext() { homecoming nextnode; }; void setnext(node * nextnode) { this->nextnode = nextnode; }; private: int object; node * nextnode; }; /* list class */ class list { public: list(); void add together (int addobject); int get(); bool next(); friend void traverse(list list); friend list addnodes(); private: int size; node * headnode; node * currentnode; node * lastcurrentnode; }; /* constructor */ list::list() { headnode = new node(); headnode->setnext(null); currentnode = null; lastcurrentnode = null; size = 0; } /* add() class method */ void list::add (int addobject) { node * newnode = new node(); newnode->set(addobject); if( currentnode != null ) { newnode->setnext(currentnode->getnext()); currentnode->setnext( newnode ); lastcurrentnode = currentnode; currentnode = newnode; } else { newnode->setnext(null); headnode->setnext(newnode); lastcurrentnode = headnode; currentnode = newnode; } size ++; } /* get() class method */ int list::get() { if (currentnode != null) homecoming currentnode->get(); } /* next() class method */ bool list::next() { if (currentnode == null) homecoming false; lastcurrentnode = currentnode; currentnode = currentnode->getnext(); if (currentnode == null || size == 0) homecoming false; else homecoming true; } /* friend function traverse linked list */ void traverse(list list) { node* savedcurrentnode = list.currentnode; list.currentnode = list.headnode; for(int = 1; list.next(); i++) { cout << "\n element " << << " " << list.get(); } list.currentnode = savedcurrentnode; } /* friend function add together nodes list */ list addnodes() { list list; list.add(2); list.add(6); list.add(8); list.add(7); list.add(1); cout << "\n list size = " << list.size <<'\n'; homecoming list; } int main() { list list = addnodes(); traverse(list); homecoming 0; }
can explain, messing up?
it seems ide not compiling 1 single file, 1 contains definition of main function. please check out how many files beingness compiled.
in addition, compiled treating warnings errors (-werror) or disable flag.
c++ gcc codeblocks gnu
Comments
Post a Comment