클래스 내부에 모든 멤버 함수 정의
class Car {
public:
void start() { cout << "Car started" << endl; }
void stop() { cout << "Car stopped" << endl; }
};
클래스 선언부와 구현부 분리
// Car.h
class Car {
public:
void start();
void stop();
};
// Car.cpp
#include "Car.h"
#include <iostream>
void Car::start() {
std::cout << "Car started" << std::endl;
}
void Car::stop() {
std::cout << "Car stopped" << std::endl;
}