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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try creating a Win32 Console Application.
It should work fine.
hongjun
It should work fine.
hongjun
ASKER
thanks for your all suggestion
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[]);