Solved

Error in performing link list

Posted on 2000-03-17
4
223 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

803 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