130 likes | 255 Views
C++ Programming Practice Time. Week 6. This. Pointer for current executing instance. Practice : Static Member. Member not on instance, but on definition Share-able in all instance of same class. File Separate. Implement. Define. Practice : Friend. Please Check Professor’s Material.
E N D
C++ Programming Practice Time Week 6.
This • Pointer for current executing instance
Practice : Static Member Member not on instance, but on definition Share-able in all instance of same class
File Separate Implement Define
Practice : Friend • Please Check Professor’s Material
Practice : Operator Overloading • Overload • operator << (int Int_Val) {printf(“%d”, Int_Val;)} • operator << (const char* pCh) {printf(“%s”, pCh;)} • … • Override • Base Class function f_A • Derived Class function f_A • BaseClass *pBc = new DerivedClass(); • pBc->f_A(); //Derived Class function f_A will be called
Inheritance • ex) • Room • Rm_Quiz, Rm_Dead, Rm_End
Protected • Allowed • Inner • Derived Class • Denied • Outer • Derived’s Derived
Constructor Chain • Base Class : Room • Derived Class : Rm_Dead • When Rm_Dead created. • 1) Room’s constructor called • 2) Rm_Dead’s constructor called • From Deep, To Shallow
Polymorphism • Override • Base Class function f_A • Derived Class function f_A • BaseClass *pBc = new DerivedClass(); • pBc->f_A(); //Derived Class function f_A will be called • Type : BaseClass • Instance : DerivedClass
Protected • Derived class will implement virtual function for its purpose