Computer-Science

Object-Oriented Programming

Object-oriented design technique using C++ Class

Contents


Priciples

스크란샷 2021-09-08 α„‹α…©α„Œα…₯ᆫ 9 18 22

Goals

스크란샷 2021-09-08 α„‹α…©α„Œα…₯ᆫ 9 26 12

Object-Oriented Software Design

Defining and Using a Class

class ClassName {
Access specifier:
  Data members;
  Member functions() { }
};

Access Specifiers

class MyClass {
public:       // public access specifier
  MyClass();  // constructor
  int x;      // public attribute

private:      // private access specifier
  int y;      // private attribute

protected:    // protected access specifier
  int z;      // protected attribute
};

Example

class Student {
public:
  string name;
  int id;
  float gpa;
  void outputInfo();
private:
  bool scholarship;
  void calcGPA();
};

Student summaCumLaude