cs31 lecture 17

A rectangle is an example object object meaningful

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: c of Workaround: declare wrapper for B 140 Declaring an object x Two important cases In a function/method that has no relation with the class int main()
 { MyClass m; MyClass } IInside a method/class nside class MyClass2 : MyClass { class MyClass m; MyClass } x For these to work (compile without error)
, the used For constructors and destructor must be accessible constructors 141 Public constructors and destructor Public x When the constructors and destructor if a class are public, When then an instance of this class can be created anywhere then When not specified by the programmer, the compiler creates When public constructor/destructor by default, for classes declared with either ‘struct’ or‘class’ either x When the constructors and destructor of a class are When protected, then an instance of this class can be created only from within a subclass of it only x When the constructors and destructor of a class are When private, then no instance of this class can be created private, 142 Pitfall: multiple inheritance x Example: Example: B : A and C : A and D : B, C (diamond)
 The attributes of A ar...
View Full Document

Ask a homework question - tutors are online