Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Error in performing link list

Posted on 2000-03-17
4
Medium Priority
?
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
loumf earned 60 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

610 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