Paper Details  
 
   

Has Bibliography
22 Pages
5416 Words

 
   
   
    Filter Topics  
 
     
   
 

Exam tests

ompiler adds an extra data member to classes that use virtual functions.This extra (hidden) data member holds the address of the class’s virtual function table.When an instance of a class is created, this data member is automatically set.What is "run time type information" (RTTI) and when might you need this information? (1 mark) Compiler fills in an instance of a type_info class with information describing class, this is typically associated with virtual table for classtypeid operator can get at type_info objectFor dynamic cast to work, it must be able to find out class of object.Explain C++'s static_cast, const_cast, dynamic_cast. (1 mark) static_cast*type* (expression)replacement for C castconst_cast*type*(expression)type will be a pointer, expression a const pointerthis is just an explicit way of saying (“I was given a const pointer, but I want to cheat”)dynamic_cast*type*(expression)type generally pointer to derived type, expression pointer to base typeinvolves run time check on types for compatibilityWhy is it inappropriate to invoke virtual member functions in the constructor of a base class? (1 mark) The wrong versions of the virtual functions would have been called.If you have to call virtual functions, it should be done as the last operation of the constructor of the most derived class.Explain the form and role of "conditional compilation macros". (1 mark) Explain the form for "header" and "implementation" files for a module that is to represent an "abstract data type" without using C++ classes (use a simple standard abstract type as an example). (1 mark) How might such a module could be extended to be a "type manager" allowing multiple instances of the abstract data type to be created (again without using C++ classes). (1 mark) "Guards constructed using #ifndef, #define, and #endif preprocessor directives are used both to avoid compilation errors that can result from multiple inclusion of a header fil...

< Prev Page 8 of 22 Next >

    More on Exam tests...

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