Class Definition

Defining Constructors

Class Implementation

Class Instantiation

Dynamic Memory Allocation

Destructors

Solve this issue of memory leaks if you try to dynamically allocate an unknown amount of data in the main

//Student.h
class Student{
	private:
		int* grades;
	public:
		Student();
		Student(int);
		~Student(); //no return like constructors
}

//Class implementation

Student::~Student():
	if(grades!= nullptr){
		delete[] grades
	}
}

Pointers to Objects

class ComplexNum{
    public:
        double real;
        double img;
        ComplexNum(double r, double i){real = r, img = i};
};

int main(){
    ComplexNum x(3,4);
    x.real = 2;
    ComplexNum* p; //pointer to ComplexNum
    p = &x;
    p-> real = 7; 
    //(*p).real =7
    
}

Pointers to Objects in Objects