Tuesday, June 20, 2006
the dot product (a scalar) tells us if two vectors are perpendecular. That is if their dot product is zero. The cross product (a vector) tells us the vector perpendicular to a plane described by two other vectors.
what is a binary search tree?
A binary tree is a binary tree representation (a maximum of 2 childern per node) in which the left node has a value smaller than the parent node and the right node has a value greater than the parent. Because of this, the complexity of searches, insertions, and deletions are O(log n) in the worste case scenario.
What don't you like about C++?
Most of the negative talk about C++ is rooted on the fact that C++ is a complex language with lots of features. For example programmers with a Java background will point to the fact that C++ doesn't have a built in garbage collector, but this also leads to better performance by C++. Others such as triditional C programmers might find the object oriented features overwhealming and perhaps even unneccessary. Some might not like it for writting small programs and relatively simple programs and might prefer to use Perl and Pascal for such tasks as C++'s features are mostly there to support larger, more complex programs.
What is a pure virtual destructor?
All destructors should be implemented as virtual if the class is meant to be a base class (ie; another class is meant to inheret from it). A destructor cannot be pure virtual since the derived class must have its own implementation of all the clean up needed in the destructor function. When a object goes out of scope (or when the object is deleted) the compiler calls the derived class destructor but it also calls the base class destructor which it wouldn't do for any other polymorphic function.
What does the extern keyword do?
Extern tells the compiler that the variable is defined elsewhere in the program (ie; in another file) and prevents redefinition and allocating new storage for the variable.
Explain insertion and deletion on a linked list.
Insertion to the head of the head or tail of a list is trivial. For example to insert to the head of the list we create a new head node and make it point to the previous head node. Insertion to other parts of the list in some order requires some sort of searching to find the correct node. The same goes for deletion of a node.
when should you pass by reference and by value?
you would pass a variable by value when you don't want the function to change the original value passed in as a parameter.
complex types, such as orrays and strings must be passed by reference since only a pointer to them can be passed in. If you don't want the function to ever change the values of a complex type parameter, you should declare the parameter as const to achieve the effects of passing by value.
complex types, such as orrays and strings must be passed by reference since only a pointer to them can be passed in. If you don't want the function to ever change the values of a complex type parameter, you should declare the parameter as const to achieve the effects of passing by value.
Describe the different types of polymorphism
static polymorphism (early binding, compile time) - function and operator overloading.
dynamic polymorphism (late binding, run time) - virtual functions.
dynamic polymorphism (late binding, run time) - virtual functions.
how does New differ from Malloc?
New doesn't require typecasting.
New is an operator, not a function (operators are faster).
New calls the constructor of the class of the object being created.
New is an operator, not a function (operators are faster).
New calls the constructor of the class of the object being created.
what is a namespace?
A namespace can be used on a related group of variables, functions and classes (any chunk of code) to give it its own scope. It is used to prevent redefinition errors when the same variable names are used inside and outside of the namespace in a seperate global variable.
Describe the different types of casting available in C++
const cast - removes const or volatile from a type.
dynamic cast - runtime upcasting or downcasting of polymorphic classes to navigate class heirarchy.
static cast - compile time casting. arithmetic, int to enum, downcasting of nonpolymorphic classes.
reinterperate cast - cast any type to any other type. dangerous.
dynamic cast - runtime upcasting or downcasting of polymorphic classes to navigate class heirarchy.
static cast - compile time casting. arithmetic, int to enum, downcasting of nonpolymorphic classes.
reinterperate cast - cast any type to any other type. dangerous.
what is volatile? what is mutable?
volatile is a c++ keyword which indicates to the compiler that the value changes often (ie; by the user) and that the cached value should not be used. The compiler then retrieves the value from the physical memory.
mutable is a c++ keyword which can be used on class member variables to indicate that their value could change, even if a const object of the class is declared.
mutable is a c++ keyword which can be used on class member variables to indicate that their value could change, even if a const object of the class is declared.
