Login

RTTI  or  Run  Time  Type  Information  is  another  feature  that  allows  flexibility  to  the  C++ programmer.  In  this  and  the  next  module,  we  will  be  throwing  some  light  on  how  RTTI functions and how a programmer can take advantage of it. RTTI is used to find out the type of an object at runtime. This is a very handy tool for making sure the object type is exactly learned before any assignment is made. We have already seen the consequences of assigning a base class object to derived and a derived class object to the base.  This  system,  being  a  runtime  component,  impacts  the  performance  of  the  system  to such a notable extent that it is usually kept disabled by default. If we want our solution to use RTTI,  we  ought  to  enable  the  RTTI.  Some  applications  can  sustain  performance  penalty  but demand  better  decision making  process  at  runtime.  For  example,  applications  which  talk  to other  applications  over  the  web.  The  performance  of  the  system  does  not  matter  as  the delay  is  largely  decided  by  the  latency  of  the  client  server  operation.  However,  if  the application is about fetching data from the local database server or communicating with the local protocol stack etc., performance cannot be ignored. We assume that the programs that we are describing in these two modules are of the type where performance is a secondary
1. If you  are  anyway  planning  to  use  virtual  functions,  the  overhead  needed  by  the  RTTI  is  not much and one can use it without being concerned much about performance.
To manage RTTI, ANSI C++ standard provided two keywords, typeid which basically indicates the type of the object, and dynamic_cast, a casting operator to cast only when the casting is safe. We will introduce typeid in this module and dynamic_cast in the next module.

Course Curriculum

Run Time Type Information 00:28:00

Course Reviews

N.A

ratings
  • 5 stars0
  • 4 stars0
  • 3 stars0
  • 2 stars0
  • 1 stars0

No Reviews found for this course.

TAKE THIS COURSE
  • FREE
  • UNLIMITED ACCESS
2 STUDENTS ENROLLED
All Rights Reserved to Extra Period. Powered by 
X