Paper Details  
 
   

Has Bibliography
22 Pages
5416 Words

 
   
   
    Filter Topics  
 
     
   
 

Exam tests

hes? (3 marks) Templates:Advantages:Robust, can handle most structure typesDisadvantages:Opaque:Advantages:Can hold anythingDisadvantages:Can hold two different types, can get confusingInheritance:Advantages:Disadvantages:Destructors. When are they needed? Why should the base class in a class hierarchy always define a virtual destructor? (1 mark) System resources must be freed; if this won’t be automatic then a destructor must do the work.In the case where a subclass may use dynamic memory the class must have a virtual destructor to implement.Explain the role of "virtual" functions in a C++ class hierarchy. (1 mark) Virtual functions provide a prototype for the later implementation of a member function of a class.Explain the three access control specifiers private, protected, and public as they apply to a class in a C++ class hierarchy. (1 mark) Private inheritance:public functions of base class are private to derived classProtected inheritance:public and protected members of base class are protected in derived classPublic inheritance:all public functions of base class are automatically in the public interface of derived classFor class Alpha, the base class of some hierarchy, with partial definition: class Alpha { public: ... intGetId() const { return this-*fId } virtual RectArea() const; virtual double PropertyX() const = 0; ... explain the differences among the three example member functions with regard to redefinition in subclasses. (1 mark) GetId() - no provision for redefinition in subclasses.Area() - Define a default implementation of the which can be overridden or extended by authors of subclasses.PropertyX() - Specify the existence of the function, providing no definition and requiring that the authors of subclasses provide definitions.Explain how a class's virtual table is used for dynamic dispatch when invoking a member function of an object referenced by a polymorphic pointer. (1 mark) The c...

< Prev Page 7 of 22 Next >

    More on Exam tests...

    Loading...
 
Copyright © 1999 - 2025 CollegeTermPapers.com. All Rights Reserved. DMCA