C++의 클래스(Class)는 구조체보다 더 효과적이다. 구조체와 클래스는 거의 흡사하게 동작하지만,
클래스에서는 내부적으로 ‘함수’를 포함할 수 있다.
ex) string class의 size() 함수
또한 클래스는 상속(Inheritance)등의 개념을 프로그램밍에서 그대로 이용할 수 있다는 점에서
객체 지향 프로그래밍(Object-Oriented Programming)을 가능하게 해주는 기본적인 단위이다.
struct
#include <iostream>
#include <string>
using namespace std;
struct student{
    string name;
    int score;
};
int main(void){
    struct student a;
    a.name="나동빈";
    a.score=100;
    cout<<a.name<<" : "<<a.score<<"점\n";
    system("puase");
    return 0;
}
class
#include <iostream>
#include <string>
using namespace std;
class Student{
private:
    string name;
    int score;
public:
    Student(string n, int s){ name=n; score=s; }
    void show(){cout<< name <<" : " << score << "점\n"; }
};
int main(void){
    Student a= Student("최정훈", 100);
    a.show();
    system("pause");
    return 0;
}
C++의 클래스(Class)를 이용해 “현실 세계의 사물”인 객체(Object)를 프로그램 내에서 구현할 수 있도록 해주며,
객체 지향 프로그래밍은 다음과 같은 특징 때문에 소스코드를 보다 간결하고 생산성 높게 만들어 준다.
1) 추상화(Abstract)
2) 캡슐화(Encapsulation)
3) 상속성(Inheritance)
4) 정보 은닉(Data Hiding)
5) 다형성(Polymorphism)
C++의 클래스 멤버(Member)멤버 변수를 속성, 혹은 프로퍼티(Property)라고 부른다.
멤버 함수를 메소드(Method)라고도 부른다.
주로 private 공간에 멤버 변수가 정의됨, public 공간에 멤버 함수가 정의됨
 C++의 클래스 인스턴스(Instance)C++에서 클래스를 활용해 만든 변수를 인스턴스(Instance)라고 한다. 실제로 프로그램 상에서 객체가 살아서 동작하도록 해준다.
하나의 클래스에서 여러 개의 서로 다른 인스턴스를 만들 수 있다.
 int main(void){
  Student a=Student("최정훈", 100);   
  a.show();
  system("pause");
}
접근 한정자public: 클래스, 멤버 등을 외부로 공개한다. 해당 객체를 사용하는 어떤 곳에서든 접근할 수 있다.
private: 클래스, 멤버 등을 내부에서만 활용한다. 외부에서 해당 객체에 접근할 수 없다.
protected:  외부에서는 접근할 수 없지만, 해당 클래스의 하위 클래스(파생된 클래스, 자식 클래스)에서는 접근 가능
클래스는 기본적으로 멤버를 private형태로 간주한다. 반대로 구조체는 기본적으로 멤버를 public으로 간주한다.
따라서 클래스에서 private: 부분을 제외하면, default 값으로 private 문법을 따른다.
클래스 내부에서 정의된 멤버 함수를 불러올 때는 멤버 참조 연산자 (.)를 사용하여 불러올 수 있다.
 #include <iostream>
#include <string>
using namespace std;
class Student{
private:
    string name;
    int englishScore;
    int mathScore;
    int getSum(){ return englishScore+mathScore; }
public:
    Student(string n, int e, int m){
        name=n;
        englishScore=e;
        mathScore=m;
    }
    void show(){ cout << name << " : [합계 " << getSum() << "점]\n"; }
};
int main(void){
    Student a= Student("최정훈", 100, 98);
    a.show();
    system("pause");
    return 0;
}
getSum()과 같이 메서드를 private에 정의함으로서 ‘정보 은닉’을 할 수 있다.
C++의 클래스 this 포인터인스턴스(Instance)는 서로 독립된 메모리 영역에 멤버 변수가 저장되고, 관리된다.
다만 멤버 함수는 모든 인스턴스가 공유한다는 점에서, 함수 내에서 인스턴스를 구분할 필요가 있다.
C++에서 this 포인터는 포인터 자료형으로 ‘상수’이기에 값을 변경할 수 없다.
this를 통해 자기 자신의 멤버 변수에 접근한다.
 #include <iostream>
#include <string>
using namespace std;
class Student{
private:
    string name;
    int englishScore;
    int mathScore;
    int getSum(){ return englishScore+mathScore; }
public:
    Student(string name, int englishScore, int mathScore){
        this->name=name;
        this->englishScore=englishScore;
        this->mathScore=mathScore;
    }
    void show(){ cout << name << " : [합계 " << getSum() << "점]\n"; }
};
int main(void){
    Student a= Student("최정훈", 100, 98);
    a.show();
    system("pause");
    return 0;
}