What Is Boyce Codd Normal Form?
A relation schema R is in BCNF with respect to a set F of functional dependencies if for all functional dependencies in F+ of the form a->b, where a and b is a subset of R, at least one of the following holds
a->b is a trivial functional dependency (b is a subset of a).
a is a superkey for schema R.
What Is Pure Virtual Function?
A class is made abstract by declaring one or more of its virtual functions to be pure. A pure virtual function is one with an initializer of = 0 in its declaration.
Write A Struct Time Where Integer M, H, S Are Its Members
struct Time
{
int m;
int h;
int s;
};
How Do You Traverse A Btree In Backward In-order?
Process the node in the right subtree.
Process the root.
Process the node in the left subtree.
What Is The Two Main Roles Of Operating System?
As a resource manager.
As a virtual machine.
In The Derived Class, Which Data Member Of The Base Class Are Visible?
In the public and protected sections.
What Is The Difference Between Realloc() And Free()?
The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no action will occur.
The realloc subroutine changes the size of the block of memory pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and returns a new pointer to the block. The pointer specified by the Pointer parameter must have been created with the malloc, calloc, or realloc subroutines and not been deallocated with the free or realloc subroutines. Undefined results occur if the Pointer parameter is not a valid pointer.
What Is Function Overloading And Operator Overloading?
Function overloading: C++ enables several functions of the same name to be defined, as long as these functions have different sets of parameters (at least as far as their types are concerned). This capability is called function overloading. When an overloaded function is called, the C++ compiler selects the proper function by examining the number, types and order of the arguments in the call. Function overloading is commonly used to create several functions of the same name that perform similar tasks but on different data types.
Operator overloading allows existing C++ operators to be redefined so that they work on objects of user-defined classes. Overloaded operators are syntactic sugar for equivalent function calls. They form a pleasant facade that doesn't add anything fundamental to the language (but they can improve understandability and reduce maintenance costs).
What Is The Difference Between Declaration And Definition?
The declaration tells the compiler that at some later point we plan to present the definition of this declaration.
E.g.: void stars () //function declaration
The definition contains the actual implementation.
E.g.
void stars () // declarator
{
for(intj=10;j > =0;j—) //function body
cout«*;
cout« endl; }
What Are The Advantages Of Inheritance In C++?
It permits code reusability. Reusability saves time in program development. It encourages the reuse of proven and debugged high-quality software, thus reducing problem after a system becomes functional.
How Do You Write A Function That Can Reverse A Linked-list?
void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
} else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0; cur-> next = head;
for(; curnext !=0;)
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}
What Do You Mean By Inline Function?
The idea behind inline functions is to insert the code of a called function at the point where the function is called. If done carefully, this can improve the application's performance in exchange for increased compile time and possibly (but not always) an increase in the size of the generated binary executables.
Write A Program That Ask For User Input From 5 To 9 Then Calculate The Average?
#include "iostream.h" intmain()
{
intMAX = 4;
int total = 0;
int average; int numb;
for (int i=0; KMAX; i++) {
cout«
"Please enter your input between 5 and 9: ";
cin » numb;
while (numb<5 || numb>9) {
cout« "Invalid input, please re-enter: ";
cin » numb;
}
total = total + numb;
}
average = total/MAX;
cout« "The average number is: "
« average « "n";
return 0;
}
Write A Short Code Using C++ To Print Out All Odd Number From 1 To 100 Using A For Loop
for( unsigned int i = 1; i < = 100; i++ )
if( l & 0x00000001 )
cout«i«",";
What Is Public, Protected, Private In C++?
Public, protected and private are three access specifiers in C++.
Public data members and member functions are accessible outside the class.
Protected data members and member functions are only available to derived classes.
Private data members and member functions can't be accessed outside the class. However there is an exception can be using friend classes.
Write A Function That Swaps The Values Of Two Integers, Using Int* As The Argument Type?
void swap(int* a, int*b)
{
intt;
t=*a;
*a = *b;
*b = t;
}
What Is Virtual Constructors/destructors?
Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object. There is a simple solution to this problem declare a virtual base-class destructor.
This makes all derived-class destructors virtual even though they don't have the same name as the base-class destructor. Now, if the object in the hierarchy is destroyed explicitly by applying the delete operator to a base-class pointer to a derived-class object, the destructor for the appropriate class is called. Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error.
What Is The Difference Between An Array And A List?
Array: is collection of homogeneous elements.
List :is collection of heterogeneous elements.
Array: memory allocated is static and continuous.
List: memory allocated is dynamic and Random.
Array: User need not have to keep in track of next memory allocation.
List: User has to keep in Track of next location where memory is allocated.
Does C++ Support Multilevel And Multiple Inheritance?
Yes.
What Is A Template In C++?
Templates allow to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until certain point they fulfill the functionality of a macro. Its prototype is any of the two following ones
template <class indetifier> functiondeclaration; template <typename indetifier> functiondeclaration;
The only difference between both prototypes is the use of keyword class or typename, its use is indistinct since both expressions have exactly the same meaning and behave exactly the same way.
Define A Constructor - What It Is And How It Might Be Called (2 Methods).
constructor is a member function of the class, with the name of the function being the same as the class name. It also specifies how the object should be initialized.
Ways of calling constructor
Implicitly: automatically by complier when an object is created.
Calling the constructors explicitly is possible, but it makes the code unverifiable.
You Have Two Pairs: New() And Delete() And Another Pair : Alloc() And Free(). Explain Differences Between Eg. New() And Malloc()
"new and delete" are preprocessors while "malloc() and free()" are functions, [we dont use brackets will calling new or delete].
no need of allocate the memory while using "new" but in "malloc()" we have to use "sizeof()".
"new" will initlize the new memory to 0 but "malloc()" gives random value in the new alloted memory location [better to use calloc()]
Write A Program That Will Convert An Integer Pointer To An Integer And Vice-versa.?
The following program demonstrates this.
#include<stdio.h>
#include<iosream>
#include<conio.h>
void main( )
{
int i = 65000 ;
int *iptr = reinterpret_cast ( i ) ;
cout << endl << iptr ;
iptr++ ;
cout << endl << iptr ;
i = reinterpret_cast ( iptr ) ;
cout << endl << i ;
i++ ;
cout << endl << i ;
}
What Is Meant By Const_cast?
The const_cast is used to convert a const to a non-const. This is shown in the following program
#include
void main( )
{
const int a = 0 ;
int *ptr = ( int * ) &a ; //one way
ptr = const_cast_ ( &a ) ; //better way
}
Here, the address of the const variable a is assigned to the pointer to a non-const variable. The const_cast is also used when we want to change the data members of a class inside the const member functions. The following code snippet shows this
class sample
{
private
int data;
public
void func( ) const
{
(const_cast (this))->data = 70 ;
}
};
What Is The Difference Between Class And Structure In C++?
Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public. Class: Class is a successor of Structure. By default all the members inside the class are private.
What Is Rtti In C++?
Runtime type identification (RTTI) lets you find the dynamic type of an object when you have only a pointer or a reference to the base type. RTTI is the official way in standard C++ to discover the type of an object and to convert the type of a pointer or reference (that is, dynamic typing). The need came from practical experience with C++. RTTI replaces many homegrown versions with a solid, consistent approach.
What Is Encapsulation In C++?
Packaging an object's variables within its methods is called encapsulation.
What Is A C++ Object?
Object is a software bundle of variables and related methods. Objects have state and behavior.
Describe Private, Protected And Public - The Differences And Give Examples.
class Point2D{ int x; int y;
public int color;
protected bool pinned;
public Point2D():x(0),y(0){} //default(no argument) constructor
};
Point2D MyPoint;
You cannot directly access private data members when they are declared (implicitly) private
MyPoint.x = 5; // Compiler will issue a compile ERROR
//Nor yoy can see them
int xdim = MyPoint.x; // Compiler will issue a compile ERROR
On the other hand, you can assign and read the public data members
MyPoint.color = 255; //no problem
int col = MyPoint.color; // no problem
With protected data members you can read them but not write them
bool isPinned = MyPoint.pinned; // no problem.
Stl Containers - What Are The Types Of Stl Containers?
There are 3 types of STL containers
Adaptive containers like queue, stack.
Associative containers like set, map.
Sequence containers like vector, deque.
Rtti - What Is Rtti In C++?
RTTI stands for "Run Time Type Identification". In an inheritance hierarchy, we can find out the exact type of the objet of which it is member. It can be done by using
dynamic id operator.
typecast operator.
Assignment Operator - What Is The Diffrence Between A "assignment Operator" And A "copy Constructor"?
In assignment operator, you are assigning a value to an existing object. But in copy constructor, you are creating a new object and then assigning a value to that object.
For example
complex cl,c2;
cl=c2; //this is assignment
complex c3=c2; //copy constructor.
If You Hear The Cpu Fan Is Running And The Monitor Power Is Still On, But You Did Not See Anything Show Up In The Monitor Screen. What Would You Do To Find Out What Is Going Wrong?
I would use the ping command to check whether the machine is still alive(connect to the network) or it is dead.
Can You Be Able To Identify Between Straight- Through And Cross- Over Cable Wiring? And In What Case Do You Use Straight- Through And Cross-over?
Straight-through is type of wiring that is one to connection, Cross- over is type of wiring which those wires are got switched We use Straight-through cable when we connect between NIC Adapter and Hub. Using Cross¬over cable when connect between two NIC Adapters or sometime between two hubs.
What Are The Defining Traits Of An Object-oriented Language?
The defining traits of an object-oriented langauge are
encapsulation,
inheritance,
polymorphism.
What Methods Can Be Overridden In Java?
In C++ terminology, all public methods in Java are virtual. Therefore, all Java methods can be overwritten in subclasses except those that are declared final, static, and private.
In C++, What Is The Difference Between Method Overloading And Method Overriding?
Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). Method overriding is the ability of the inherited class rewriting the virtual method of the base class.
What Is The Difference Between Mutex And Binary Semaphore?
semaphore is used to synchronize processes, where as mutex is used to provide synchronization between threads running in the same process.
Are There Any New Intrinsic (built-in) Data Types?
Yes. The ANSI committee added the bool intrinsic type and its true and false value keywords.
What Problem Does The Namespace Feature Solve?
Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries. The namespace feature surrounds a library's external declarations with a unique namespace that eliminates the potential for those collisions.
This solution assumes that two library vendors don't use the same namespace identifier, of course.
Describe Run-time Type Identification?
The ability to determine at run time the type of an object by using the typeid operator or the dynamiccast operator.
What Is The Standard Template Library (stl)?
A library of container templates approved by the ANSI committee for inclusion in the standard C++ specification.
A programmer who then launches into a discussion of the generic programming model, iterators, allocators, algorithms, and such, has a higher than average understanding of the new technology that STL brings to C++ programming.
What Is An Explicit Constructor?
A conversion constructor declared with the explicit keyword. The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction.
What Is A Mutable Member?
One that can be modified by the class even when the object of the class or the member function doing the modification is const.
When Is A Template A Better Solution Than A Base Class?
When you are designing a generic class to contain or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or management, and particularly when those other types are unknown (thus, the genericity) to the designer of the container or manager class.
Explain The Isa And Hasa Class Relationships. How Would You Implement Each In A Class Design?
A specialized class "is" a specialization of another class and, therefore, has the ISA relationship with the other class. An Employee ISA Person. This relationship is best implemented with inheritance. Employee is derived from Person. A class may have an instance of another class. For example, an employee "has" a salary, therefore the Employee class has the HASA relationship with the Salary class. This relationship is best implemented by embedding an object of the Salary class in the Employee class.
A relation schema R is in BCNF with respect to a set F of functional dependencies if for all functional dependencies in F+ of the form a->b, where a and b is a subset of R, at least one of the following holds
a->b is a trivial functional dependency (b is a subset of a).
a is a superkey for schema R.
What Is Pure Virtual Function?
A class is made abstract by declaring one or more of its virtual functions to be pure. A pure virtual function is one with an initializer of = 0 in its declaration.
Write A Struct Time Where Integer M, H, S Are Its Members
struct Time
{
int m;
int h;
int s;
};
How Do You Traverse A Btree In Backward In-order?
Process the node in the right subtree.
Process the root.
Process the node in the left subtree.
What Is The Two Main Roles Of Operating System?
As a resource manager.
As a virtual machine.
In The Derived Class, Which Data Member Of The Base Class Are Visible?
In the public and protected sections.
Capgemini Frequently Asked C++ Interview Questions Answers |
What Is The Difference Between Realloc() And Free()?
The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no action will occur.
The realloc subroutine changes the size of the block of memory pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and returns a new pointer to the block. The pointer specified by the Pointer parameter must have been created with the malloc, calloc, or realloc subroutines and not been deallocated with the free or realloc subroutines. Undefined results occur if the Pointer parameter is not a valid pointer.
What Is Function Overloading And Operator Overloading?
Function overloading: C++ enables several functions of the same name to be defined, as long as these functions have different sets of parameters (at least as far as their types are concerned). This capability is called function overloading. When an overloaded function is called, the C++ compiler selects the proper function by examining the number, types and order of the arguments in the call. Function overloading is commonly used to create several functions of the same name that perform similar tasks but on different data types.
Operator overloading allows existing C++ operators to be redefined so that they work on objects of user-defined classes. Overloaded operators are syntactic sugar for equivalent function calls. They form a pleasant facade that doesn't add anything fundamental to the language (but they can improve understandability and reduce maintenance costs).
What Is The Difference Between Declaration And Definition?
The declaration tells the compiler that at some later point we plan to present the definition of this declaration.
E.g.: void stars () //function declaration
The definition contains the actual implementation.
E.g.
void stars () // declarator
{
for(intj=10;j > =0;j—) //function body
cout«*;
cout« endl; }
What Are The Advantages Of Inheritance In C++?
It permits code reusability. Reusability saves time in program development. It encourages the reuse of proven and debugged high-quality software, thus reducing problem after a system becomes functional.
How Do You Write A Function That Can Reverse A Linked-list?
void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
} else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0; cur-> next = head;
for(; curnext !=0;)
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}
What Do You Mean By Inline Function?
The idea behind inline functions is to insert the code of a called function at the point where the function is called. If done carefully, this can improve the application's performance in exchange for increased compile time and possibly (but not always) an increase in the size of the generated binary executables.
Write A Program That Ask For User Input From 5 To 9 Then Calculate The Average?
#include "iostream.h" intmain()
{
intMAX = 4;
int total = 0;
int average; int numb;
for (int i=0; KMAX; i++) {
cout«
"Please enter your input between 5 and 9: ";
cin » numb;
while (numb<5 || numb>9) {
cout« "Invalid input, please re-enter: ";
cin » numb;
}
total = total + numb;
}
average = total/MAX;
cout« "The average number is: "
« average « "n";
return 0;
}
Write A Short Code Using C++ To Print Out All Odd Number From 1 To 100 Using A For Loop
for( unsigned int i = 1; i < = 100; i++ )
if( l & 0x00000001 )
cout«i«",";
What Is Public, Protected, Private In C++?
Public, protected and private are three access specifiers in C++.
Public data members and member functions are accessible outside the class.
Protected data members and member functions are only available to derived classes.
Private data members and member functions can't be accessed outside the class. However there is an exception can be using friend classes.
Write A Function That Swaps The Values Of Two Integers, Using Int* As The Argument Type?
void swap(int* a, int*b)
{
intt;
t=*a;
*a = *b;
*b = t;
}
What Is Virtual Constructors/destructors?
Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object. There is a simple solution to this problem declare a virtual base-class destructor.
This makes all derived-class destructors virtual even though they don't have the same name as the base-class destructor. Now, if the object in the hierarchy is destroyed explicitly by applying the delete operator to a base-class pointer to a derived-class object, the destructor for the appropriate class is called. Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error.
What Is The Difference Between An Array And A List?
Array: is collection of homogeneous elements.
List :is collection of heterogeneous elements.
Array: memory allocated is static and continuous.
List: memory allocated is dynamic and Random.
Array: User need not have to keep in track of next memory allocation.
List: User has to keep in Track of next location where memory is allocated.
Does C++ Support Multilevel And Multiple Inheritance?
Yes.
What Is A Template In C++?
Templates allow to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until certain point they fulfill the functionality of a macro. Its prototype is any of the two following ones
template <class indetifier> functiondeclaration; template <typename indetifier> functiondeclaration;
The only difference between both prototypes is the use of keyword class or typename, its use is indistinct since both expressions have exactly the same meaning and behave exactly the same way.
Define A Constructor - What It Is And How It Might Be Called (2 Methods).
constructor is a member function of the class, with the name of the function being the same as the class name. It also specifies how the object should be initialized.
Ways of calling constructor
Implicitly: automatically by complier when an object is created.
Calling the constructors explicitly is possible, but it makes the code unverifiable.
You Have Two Pairs: New() And Delete() And Another Pair : Alloc() And Free(). Explain Differences Between Eg. New() And Malloc()
"new and delete" are preprocessors while "malloc() and free()" are functions, [we dont use brackets will calling new or delete].
no need of allocate the memory while using "new" but in "malloc()" we have to use "sizeof()".
"new" will initlize the new memory to 0 but "malloc()" gives random value in the new alloted memory location [better to use calloc()]
Write A Program That Will Convert An Integer Pointer To An Integer And Vice-versa.?
The following program demonstrates this.
#include<stdio.h>
#include<iosream>
#include<conio.h>
void main( )
{
int i = 65000 ;
int *iptr = reinterpret_cast ( i ) ;
cout << endl << iptr ;
iptr++ ;
cout << endl << iptr ;
i = reinterpret_cast ( iptr ) ;
cout << endl << i ;
i++ ;
cout << endl << i ;
}
What Is Meant By Const_cast?
The const_cast is used to convert a const to a non-const. This is shown in the following program
#include
void main( )
{
const int a = 0 ;
int *ptr = ( int * ) &a ; //one way
ptr = const_cast_ ( &a ) ; //better way
}
Here, the address of the const variable a is assigned to the pointer to a non-const variable. The const_cast is also used when we want to change the data members of a class inside the const member functions. The following code snippet shows this
class sample
{
private
int data;
public
void func( ) const
{
(const_cast (this))->data = 70 ;
}
};
What Is The Difference Between Class And Structure In C++?
Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public. Class: Class is a successor of Structure. By default all the members inside the class are private.
What Is Rtti In C++?
Runtime type identification (RTTI) lets you find the dynamic type of an object when you have only a pointer or a reference to the base type. RTTI is the official way in standard C++ to discover the type of an object and to convert the type of a pointer or reference (that is, dynamic typing). The need came from practical experience with C++. RTTI replaces many homegrown versions with a solid, consistent approach.
What Is Encapsulation In C++?
Packaging an object's variables within its methods is called encapsulation.
What Is A C++ Object?
Object is a software bundle of variables and related methods. Objects have state and behavior.
Describe Private, Protected And Public - The Differences And Give Examples.
class Point2D{ int x; int y;
public int color;
protected bool pinned;
public Point2D():x(0),y(0){} //default(no argument) constructor
};
Point2D MyPoint;
You cannot directly access private data members when they are declared (implicitly) private
MyPoint.x = 5; // Compiler will issue a compile ERROR
//Nor yoy can see them
int xdim = MyPoint.x; // Compiler will issue a compile ERROR
On the other hand, you can assign and read the public data members
MyPoint.color = 255; //no problem
int col = MyPoint.color; // no problem
With protected data members you can read them but not write them
bool isPinned = MyPoint.pinned; // no problem.
Stl Containers - What Are The Types Of Stl Containers?
There are 3 types of STL containers
Adaptive containers like queue, stack.
Associative containers like set, map.
Sequence containers like vector, deque.
Rtti - What Is Rtti In C++?
RTTI stands for "Run Time Type Identification". In an inheritance hierarchy, we can find out the exact type of the objet of which it is member. It can be done by using
dynamic id operator.
typecast operator.
Assignment Operator - What Is The Diffrence Between A "assignment Operator" And A "copy Constructor"?
In assignment operator, you are assigning a value to an existing object. But in copy constructor, you are creating a new object and then assigning a value to that object.
For example
complex cl,c2;
cl=c2; //this is assignment
complex c3=c2; //copy constructor.
If You Hear The Cpu Fan Is Running And The Monitor Power Is Still On, But You Did Not See Anything Show Up In The Monitor Screen. What Would You Do To Find Out What Is Going Wrong?
I would use the ping command to check whether the machine is still alive(connect to the network) or it is dead.
Can You Be Able To Identify Between Straight- Through And Cross- Over Cable Wiring? And In What Case Do You Use Straight- Through And Cross-over?
Straight-through is type of wiring that is one to connection, Cross- over is type of wiring which those wires are got switched We use Straight-through cable when we connect between NIC Adapter and Hub. Using Cross¬over cable when connect between two NIC Adapters or sometime between two hubs.
What Are The Defining Traits Of An Object-oriented Language?
The defining traits of an object-oriented langauge are
encapsulation,
inheritance,
polymorphism.
What Methods Can Be Overridden In Java?
In C++ terminology, all public methods in Java are virtual. Therefore, all Java methods can be overwritten in subclasses except those that are declared final, static, and private.
In C++, What Is The Difference Between Method Overloading And Method Overriding?
Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). Method overriding is the ability of the inherited class rewriting the virtual method of the base class.
What Is The Difference Between Mutex And Binary Semaphore?
semaphore is used to synchronize processes, where as mutex is used to provide synchronization between threads running in the same process.
Are There Any New Intrinsic (built-in) Data Types?
Yes. The ANSI committee added the bool intrinsic type and its true and false value keywords.
What Problem Does The Namespace Feature Solve?
Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries. The namespace feature surrounds a library's external declarations with a unique namespace that eliminates the potential for those collisions.
This solution assumes that two library vendors don't use the same namespace identifier, of course.
Describe Run-time Type Identification?
The ability to determine at run time the type of an object by using the typeid operator or the dynamiccast operator.
What Is The Standard Template Library (stl)?
A library of container templates approved by the ANSI committee for inclusion in the standard C++ specification.
A programmer who then launches into a discussion of the generic programming model, iterators, allocators, algorithms, and such, has a higher than average understanding of the new technology that STL brings to C++ programming.
What Is An Explicit Constructor?
A conversion constructor declared with the explicit keyword. The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction.
What Is A Mutable Member?
One that can be modified by the class even when the object of the class or the member function doing the modification is const.
When Is A Template A Better Solution Than A Base Class?
When you are designing a generic class to contain or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or management, and particularly when those other types are unknown (thus, the genericity) to the designer of the container or manager class.
Explain The Isa And Hasa Class Relationships. How Would You Implement Each In A Class Design?
A specialized class "is" a specialization of another class and, therefore, has the ISA relationship with the other class. An Employee ISA Person. This relationship is best implemented with inheritance. Employee is derived from Person. A class may have an instance of another class. For example, an employee "has" a salary, therefore the Employee class has the HASA relationship with the Salary class. This relationship is best implemented by embedding an object of the Salary class in the Employee class.
Post a Comment