kiem tien, kiem tien online, kiem tien truc tuyen, kiem tien tren mang
Tuesday, October 4, 2011

Source:  http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/cf3b6326-6e58-4b85-afb1-2694a1450128/


I recently installed VC++ 2005 EXP edition.
1) I created a project name Radius and created two new items hello.cpp and area.cpp.
2) area.cpp is the first item and hello.cpp is the second one.
3) When I build the project Radius, I got the error
LNK2005: _main already defined in area.obj
*********************************************************************************************************************************************************************
This error is because of multiple definitions of main. You must have defined main in area.cpp as well as in hello.cpp. In C/C++ programs, you can write only one main per application.
Remove one definition of main and it should work fine.
Cheers
*************************************************************************************************************************************
I think what you are trying to do is....

1.) File: hello.cpp
#include <IOSTREAM>
#include <RADIUS.H>

int main(int argc, char *argv[])
{
float area = get_area(5);
printf("Area of circle with radius %d = %f\n", 5, area);
}
2.) File: radius.h
float get_area(float radius);
float get_circumference(float radius);
3.) File: radius.cpp
#include <RADIUS.H>

float get_area(float radius)
{
return (3.14159 * radius * radius);
}

float get_circumference(float radius)
{
return (3.14159 * (radius * 2));
}

0 comments:

Post a Comment

domain, domain name, premium domain name for sales

Popular Posts