멤버 메서드의 선언, 정의 분리

2022. 4. 10. 11:22C++

//멤버 메서드의 선언, 정의 분리하기

#include <iostream>

using namespace std;

class Vector2{
public:
    Vector2();
    Vector2(float x, float y);

    float GetX() const;
    float GetY() const;
private:
    float x;
    float y;
};

int main(){

}

Vector2::Vector2() :x(0), y(0){ }
Vector2::Vector2(float x, float y): x(x), y(y) { }

float Vector2::GetX() const {return x;}
float Vector2::GetY() const {return y;}

'C++' 카테고리의 다른 글

friend  (0) 2022.04.10
연산자 오버로딩  (0) 2022.04.10
예외처리  (0) 2022.04.10
범위지정 연산자  (0) 2022.04.09
inline 함수  (0) 2022.04.09