Shared Flashcard Set

Details

RTTI
n/a
23
Computer Science
Undergraduate 2
01/16/2009

Additional Computer Science Flashcards

 


 

Cards

Term
What does RTTI stand for?
Definition
runtime type identification
Term
What is the purpose of RTTI?
Definition
provide a standard way for a program to determine the type of object during runtime
Term
What are the three components that support RTTI?
Definition
dynamic_cast, typeid, type_info
Term
What can only use RTTI?
Definition
class hierarchy that has virtual functions
Term
What does dynamic_cast do?
Definition
tells whether you can safely assign the address of an object to a point of a particular type
Term
What does the typeid operator let you do?
Definition
determine whether two objects are the same type
Term
What arguments do typeid accept?
Definition
The name of a class

An expression that evaluates to an object

Term
what does typeid operator return?
Definition
a reference to a type_info object
Term
what header file is the class type_info defined in?
Definition
the typeinfo
Term
What operators does type_info overload?
Definition
== and !=

so you can use these operators to compare types
ex.
typeid(Magnificent) == typeid(*pg)

Term
What does name() return?
Definition
implementation-dependent string that is typically the name of the class

ex
cout << "Now processing type " << typeid(*pg).name();

Term
eofbit
Definition
Is set to 1 if end-of-file reached
Term
badbit
Definition
Is set to 1 if the stream may be corrupted;
for example, there could have been a file read error
Term
failbit
Definition
Is set to 1 if an input operation failed to read the expected characters or an output operation failed to write the expected characters
Term
goodbit
Definition
Another way of saying 0
Term
good()
Definition
returns true if the stream can be used (all bits are cleared)
Term
eof()
Definition
returns true if eofbit is set
Term
bad()
Definition
returns true if badbit is set
Term
fail()
Definition
returns true if badbit or failbit is set
Term
rdstate()
Definition
returns the stream state
Term
expections(iostate ex)
Definition
sets which states will cause clear() to throw an exception;
for example, if ex is eofbit, then clear() will throw an exception if eofbit is set
Term
clear(iostate s)
Definition
sets the stream state to s; the default for s is 0 (goodbit); throws a basic_ios::failure exception if rdstate() & exceptions()) != 0
Term
setstate(iostate s)
Definition
Calls clear(rdstate() | s). This sets stream state bits corresponding to those bits set in s; other stream state bits are left unchanged
Supporting users have an ad free experience!