473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

link error

************************************************
#include <iostream>
#include <string>
using namespace std;

class Shape
{
public:
Shape(void) {}
~Shape(void) {}
virtual void draw(void) const { cout<<"Shape draw"<<endl; }
};

class Rectangle : public Shape
{
public:
Rectangle(void) {}
~Rectangle(void) {}
void draw(void) const { cout<<"Rectangle draw"<<endl; }
};

class Ellipse : public Shape
{
public:
Ellipse(void) {}
~Ellipse(void) {}
};

int _tmain(int argc, char* argv[])
{
Shape *pr = new Rectangle;
pr->draw();
pr->Shape::draw();
delete pr;
pr = NULL;

Shape *pe = new Ellipse;
pe->draw();
delete pe;
pe = NULL;

return 0;
}

--------------------Configuration: virturnl - Win32
Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/virturnl.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

virturnl.exe - 2 error(s), 0 warning(s)

************************************************
My IDE tool is VC++6.0 , when i want to build the code, the errors will
display when it linked. but i have never meet the error , have anyone known
whats wrong with it and give me an advice , thanks
May 22 '06 #1
2 1887
wenqiang.zhou wrote:
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/virturnl.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

virturnl.exe - 2 error(s), 0 warning(s)

A C++ program must have a main() function, yours does not, hence the error.

--
Ian Collins.
May 22 '06 #2
wenqiang.zhou <we***********@jrdcom.com> wrote:
************************************************
#include <iostream>
#include <string>
using namespace std;

class Shape
{
public:
Shape(void) {}
~Shape(void) {}
Your destructor should be virtual, since in _tmain() you are deleting a
derived class through a base class pointer.
virtual void draw(void) const { cout<<"Shape draw"<<endl; }
};

class Rectangle : public Shape
{
public:
Rectangle(void) {}
~Rectangle(void) {}
void draw(void) const { cout<<"Rectangle draw"<<endl; }
};

class Ellipse : public Shape
{
public:
Ellipse(void) {}
~Ellipse(void) {}
};

int _tmain(int argc, char* argv[])
Non-standard. Try:

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

or since you are not using any command line arguments:

int main()
{
Shape *pr = new Rectangle;
pr->draw();
pr->Shape::draw();
delete pr;
pr = NULL;

Shape *pe = new Ellipse;
pe->draw();
delete pe;
pe = NULL;

return 0;
}

--------------------Configuration: virturnl - Win32
Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main


See above, maybe VC++6.0 doesn't like _tmain instead of main.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
May 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matthew Houseman | last post by:
All, I've created a synonym that points to a package over a database link like so: CREATE SYNONYM API_MYLINK FOR USER.CSAPI_V2@INSTANCE.DOMAIN.COM I've granted execute like so: grant execute...
1
by: Andrew V. Romero | last post by:
I have a script that I am working on for an intranet tool and in this script I have a form, which when submitted the onSubmit command calls calculate(). In this calculate function, I have it do...
10
by: Gary Hughes | last post by:
I'm getting the following error when attempting to link a managed C++ dll. I can't find any reference to these errors with google. Can anyone help? I've included the class definition causing the...
10
by: Ian Lazarus | last post by:
Hello. How do "unresolved token" link errors occur. How do I fix them? Linking... LINK : error LNK2020: unresolved token (0A000015) ??_7type_info@@6B@ LINK : error LNK2020: unresolved token...
4
by: Jun | last post by:
anyone know how this error shows? how can i solve this? LINK : error LNK2020: unresolved token (0A0000EA) _AtlBaseModule LINK : error LNK2020: unresolved token (0A0000EC) atlTraceGeneral LINK :...
13
by: rdemyan via AccessMonster.com | last post by:
My front-end code manually links to the backend file. I was wondering what stops Access from linking to the system tables in the backend file. Is it just by virtue that they are hidden? This...
5
by: Bruce | last post by:
I am getting a lot of link errors when compiling in the debug build but not release. I am compiling a CLR managed code class library. I believe the link errors are actually being caused by a...
10
richardhodge
by: richardhodge | last post by:
I am a VB6 database programmer and have run into a small problem. The company I work for primarily uses Microsoft Access 2000 for the database that is the back end for our software. Well the...
7
by: ApexData | last post by:
Hello I currently Link the FE/BE using the LinkTables Option and the Linked Table Manager. Any time I need to move the BE to another location, I have to go through this process over again. I...
3
by: Kevin | last post by:
Hi guys, I am a beginner for QT, and I installed the free qt 2.3 under windows (XP), as well as the MS's free VC expression edition (for their compilers, linkers, etc), and the SDK tool. My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.