Uploaded by dosisoh633

T180

advertisement
!T180












Polymorphism
o Compile time- function overloading
o Run time- Function overriding
If a function isn’t virtual a base class pointer will always call the base class function
Arrays- multiple elements of a datatype
Overloading- Operator and Function
Constructors- Default, parameterized, and copy A copy(A_object){};
Pointer- special variables that hold the address of another variable
Address- the location of the variable in memory
Memory on the heap needs to be dealt with manually
o delete ptr;
o delete[] ptr2;
o To avoid dangling pointer- do ptr = NULL;
Abstraction
o One virtual function makes a class abstract
o If you don’t override the virtual function in the derived class, the derived class also
becomes a abstract class
Inheritance
o 3 modes- public, protected, and private
o 5 types- Single, multiple, hierarchical, multi-level, and hybrid.
o Diamond problem- derived class has two references to the same function and thus
throws error. Solution- make 2nd level class have virtual function.
Compilation steps
o Pre-processing
o Compiling- basically translates code into machine language.
o Linking- runtime
OOP conceptso
Download