헤더파일에 클래스를 하나 정의하였는데 컴파일 오류가 납니다.

bissanmu의 이미지

Beginning C++ 실습중에 헤더파일에 Box.h 를 정의해두고
Box.cpp 를 컴파일했는데 아래와 같은 오류가 납니다.

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

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

인터넷에서 예제파일 다운 받았는데 같은 오류가 나더라구요 . 타이핑 잘 못 한건 아닌것 같은데 무슨 오류일까요?

// Box.h
#ifndef BOX_H
#define BOX_H

class Box {
public:
double length;
double width;
double height;

// Constructor
Box(double lengthValue, double widthValue, double heightValue);

// Function to calculate the volume of a box
double volume();
};

#endif

----------------------------------------------------------------------------
// Box.cpp
#include
#include "Box.h"

using std::cout;
using std::endl;

// Constructor definition
Box::Box(double lengthValue, double widthValue, double heightValue) {
cout << "Box constructor called" << endl;
length = lengthValue;
width = widthValue;
height = heightValue;
}

// Function to calculate the volume of a box
double Box::volume() {
return length * width * height;
}

M.W.Park의 이미지

DLL이 아닌 이상 main 함수가 있어야겠죠? ^^;

-----
오늘 의 취미는 끝없는, 끝없는 인내다. 1973 法頂

-----
오늘 의 취미는 끝없는, 끝없는 인내다. 1973 法頂

bissanmu의 이미지

int main() 포함시켜 주었는데 에러가 11개로 더 아졌습니다. ;;;

klara의 이미지

에러가 나면에러를 적으세요.

simpid의 이미지

c 에 대해서 거의 모르시는것 같네요.

설마 int main() 만 추가하신건 아니시죠?

int main()
{
 return 0;
}

이라고 해주셔야 합니다.

제 답변이 틀렸다면...
새로 발생한 11개 에러를 올려주시면 정확한 답변을 드릴 수 있습니다.