[Object.h]
#include "Point"
class Object
{
static constexpr const Point pos = {0.5f, 0.5f}
...
}
[Point.h]
class Point
{
float x= 0.f, y = 0.f;
public:
constexpr Point(float x, float y);
...
}
[Point.cpp]
#include "Point.h"
constexpr Point::Point(float x,float y) : x(x), y(y) {}
...
이렇게 구현했는데 Object 클래스 pos 부분에서 C2131오류가 발생하네요..
그런데, Point 클래스의 생성자를 선언, 정의 분리하지 않고 그냥 헤더파일에 넣으면 제대로 컴파일이 되는데
constexpr 생성자는 헤더파일에 작성해야 하나요?
찾아보니까 constexpr constructor는 암시적으로 inline이고, 사용되는 곳에서 define되어야 한대. 그래서 header에다가 정의하라는데
아하 감사합니다.
constexpr const ㅗㅜㅑ