I'm having two errors everytime I try to debug a simple project in Visual Studio 2010.
Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\Users\Fighter\Documents\C++\Point\Point\MSVCRTD.lib(crtexe.obj) Point
Error 2 error LNK1120: 1 unresolved externals C:\Users\Fighter\Documents\C++\Point\Debug\Point.exe 1 1 Point
this is a simple code I'm using to try my program in VS :
class Point
{
private:
int x;
int y;
};
The problem is that this thing w开发者_StackOverflow中文版orks great in Code::Blocks but whith VS it gives me those errors.
What's the problem here.
Thanks
Your program needs a main() function to be valid.
int main(int argc, char* argv[])
{
Point p;
return 0;
}
The compiler says to you that he wants you to define an entry point to your application. (a.k.a a function main.)
You need to define a function named main()
or main(int argc, char **argv)
.
Every C++ program must have a function called main()
. It can take one of two forms:
int main()
int main(int argc, char* argv[])
Implement one of these (probably the first), and recompile.
精彩评论