Link to home
Start Free TrialLog in
Avatar of eddyhalim
eddyhalim

asked on

Error in performing link list

I have a problem in compiling this source code , can someone help me to solve it. i'm using VC++6.

the source:


#include<iostream.h>


struct link
{
      int data;
      link* next;
};

class linklist
{
private:
      link* front;
public:
      linklist()
      {front = NULL;}
      void additem(int d);
      void display();
};

void linklist::additem(int d)
{
      link* newlink = new link;
      newlink->data = d;
      newlink->next = front;
      front=newlink;
}

 void linklist::display()
{
      link* current = front;
      while(current != NULL)
      {
            cout<<endl<<current->data;
            current=current->next;
      }
}


void main()
{

      linklist l1;

      l1.additem(20);
      l1.additem(50);

      l1.display();

}



the error:

Linking...
libcd.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/testlink.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

But when i compile with VC++ 5 it doesn't have any error.
ASKER CERTIFIED SOLUTION
Avatar of loumf
loumf

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wylliker
wylliker

How did you set up your project?

You can't use main as your entry point unless you are using a Console App.

You need to create a new project.

Second, main() should be declared as:

int main( int argc, char *argv[]);




Try creating a Win32 Console Application.

It should work fine.

hongjun
Avatar of eddyhalim

ASKER

thanks for your all suggestion