cpp (1) 썸네일형 리스트형 C++에서 헤더와 소스 (.h/.hpp vs .cpp) 헤더와 소스C++ 프로젝트에서는 다음과 같이 헤더와 소스가 분리된 모습을 볼 수 있다. // Vector.h#ifndef VECTOR_H#define VECTOR_Hclass Vector {private: double x, y;public: Vector(double x, double y); double length() const;};#endif // Vector.cpp#include "Vector.h"#include Vector::Vector(double x, double y) : x(x), y(y) {}double Vector::length() const { return std::sqrt(x * x + y * y);} C++에서는 헤더 파일과 소스 파일을 따로 분리하는 것이 일반적.. 이전 1 다음