Solved

Error in performing link list

Posted on 2000-03-17
4
218 Views
Last Modified: 2010-04-02
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.
0
Comment
Question by:eddyhalim
4 Comments
 
LVL 1

Accepted Solution

by:
loumf earned 20 total points
ID: 2630329
Create a new Console project and add this file to it.  Should compile fine.  Looks like you accidentally created a windows program project.
0
 
LVL 4

Expert Comment

by:wylliker
ID: 2630338
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[]);




0
 
LVL 33

Expert Comment

by:hongjun
ID: 2630401
Try creating a Win32 Console Application.

It should work fine.

hongjun
0
 

Author Comment

by:eddyhalim
ID: 2643722
thanks for your all suggestion
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now