< 1 2 3 4 5 6 7 > >>   Sort: Date

Anything wrong with this code?
Anything wrong with this code? T *p = 0; delete p; Note: Typical wrong answer: Yes, the program will crash in an attempt to delete a null pointer. The candidate does not understand pointers. A very smart candidate will ask whether delete is overloaded for the class T.
2012-05-10, 3333👍, 0💬

Consider the following struct declarations:
Consider the following struct declarations: struct A { A(){ cout &lt;&lt; "A"; } }; struct B { B(){ cout &lt;&lt; "B"; } }; struct C { C(){ cout &lt;&lt; "C"; } }; struct D { D(){ cout &lt;&lt; "D"; } }; struct E : D { E(){ cout &lt;&lt; "E"; } }; struct F : A...
2012-05-09, 3327👍, 0💬

Explain which of the following declarations will compile and what will be constant
Explain which of the following declarations will compile and what will be constant - a pointer or the value pointed at: * const char * * char const * * char * const Note: Ask the candidate whether the first declaration is pointing to a string or a single character. Both explanations are correct, but...
2012-05-07, 3305👍, 0💬

Anything wrong with this code?
Anything wrong with this code? T *p = new T[10]; delete p; Note: Incorrect replies: “No, everything is correct”, “Only the first element of the array will be deleted”, “The entire array will be deleted, but only the first element destructor will be called”.
2012-05-09, 3292👍, 0💬

What problems might the following macro bring to the application?
What problems might the following macro bring to the application? #define sq(x) x*x
2012-05-08, 3268👍, 0💬

What is RTTI? C++
What is RTTI? C++ Answer1. 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: 1) dynamic id operator 2) typecast operator Answer2. RTTI is defined as follows: Run Time Type Informati...
2012-04-02, 3239👍, 0💬

What is semaphore? C++
What is semaphore? C++ Semaphore is a special variable, it has two methods: up and down. Semaphore performs atomic operations, which means ones a semaphore is called it can not be inturrupted. The internal counter (= #ups - #downs) can never be negative. If you execute the “down” method when the int...
2012-04-09, 3184👍, 0💬

Referring to the sample code above, what is the ....
Sample Code class HasStatic { static int I; }; Referring to the sample code above, what is the appropriate method of defining the member variable "I", and assigning it the value 10, outside of the class declaration? 1 int static I = 10; 2 int HasStatic::I = 10; 3 HasStatic I = 10; 4 static I(10); 5 ...
2012-05-04, 3174👍, 0💬

What is a template? C++
What is a template? 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 followi...
2012-02-03, 3165👍, 0💬

What is an orthogonal base class? C++
What is an orthogonal base class? C++ If two base classes have no overlapping methods or data they are said to be independent of, or orthogonal to each other. Orthogonal in the sense means that two classes operate in different dimensions and do not interfere with each other in any way. The same deri...
2012-01-16, 3164👍, 0💬

Your manager has asked you to integrate an existing project
Scenario:- Your manager has asked you to integrate an existing project with an external timer. Her requirements include adding a global variable whose contents can be only read by the software but whose value will be continuously updated by the hardware clock. Referring to the above scenario, which ...
2012-04-26, 3128👍, 0💬

What is output equal to in Bitwise Operations - ...
What is output equal to in Bitwise Operations - ... What is output equal to in Bitwise Operations - Given inputs X, Y, Z and operations | and & (meaning bitwise OR and AND, respectively), what is output equal to in? output = (X & Y) | (X & Z) | (Y & Z);
2012-04-04, 3115👍, 0💬

Assuming that all the necessary standard headers ....
using namespace std; string s("abcdefghijk"); string::size_type I = s.find_first_of("a-c"); s = string(s, I, string::npos); I = s.find_first_not_of("a-e"); cout << string(s, I, string::npos); Assuming that all the necessary standard headers have been included, what is the output produced be th...
2012-05-03, 3068👍, 0💬

Giving the following class definitions, how many subobjects of class V in class X?
Giving the following class definitions, how many subobjects of class V in class X? class V { /* ... */ }; class B1 : virtual public V { /* ... */ }; class B2 : virtual public V { /* ... */ }; class B3 : public V { /* ... */ }; class X : public B1, public B2, public B3 { /* ... */};
2012-04-27, 3064👍, 0💬

Virtual Destructor - What is the need for “Virtual Destructor”?
Virtual Destructor - What is the need for “Virtual Destructor”? Destructors are declared as virtual because if do not declare it as virtual the base class destructor will be called before the derived class destructor and that will lead to memory leak because derived class’s objects will not get fre...
2012-04-03, 3047👍, 0💬

Which one of the following operators can only be ....
Which one of the following operators can only be overridden when implemented as a member function of the class it is being implemented for? 1 == (double equal) 2 + (plus) 3 ! (exclamation point) 4 = (equal) 5 & (ampersand)
2012-05-04, 3015👍, 0💬

Design and implement a String class that satisfies the following:
Design and implement a String class that satisfies the following: * Supports embedded nulls * Provide the following methods (at least) o Constructor o Destructor o Copy constructor o Assignment operator o Addition operator (concatenation) o Return character at location o Return substring at location...
2012-04-18, 2990👍, 0💬

Assuming that all the necessary standard headers have been ....
class Parent { public: Parent () { Status () ; } virtual ~Parent () { Status () ; } virtual void Status () { cout << "Parent "; } } ; class Child : public Parent { public: Child () { Status () ; } virtual ~Child () { Status () ; } virtual void Status () { cout &lt;&lt; "Child " ; } } ;...
2012-05-03, 2979👍, 0💬

Differences of C and C++ Could you write a small program that will compile in “C” but not in “C++”?
Differences of C and C++ Could you write a small program that will compile in “C” but not in “C++”? In C, if you can a const variable e.g. const int i = 2; you can use this variable in other module as follows extern const int i; C compiler will not complain. But for C++ compiler u must write extern...
2012-04-03, 2977👍, 0💬

Describe one simple rehashing policy.
Describe one simple rehashing policy. The simplest rehashing policy is linear probing. Suppose a key K hashes to location i. Suppose other key occupies H[i]. The following function is used to generate alternative locations: rehash(j) = (j + 1) mod h where j is the location most recently probed. Init...
2012-04-16, 2958👍, 0💬

.Write a short code using C++ to print out all odd number from 1 to 100 using a for loop
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 &lt; = 100; i++ ) if( i & 0x00000001 ) cout &lt;&lt; i&lt;&lt;",";
2012-04-18, 2957👍, 0💬

Which type conditional expression is used when a developer wants to execute a statement only once when a given condition is
Which type conditional expression is used when a developer wants to execute a statement only once when a given condition is met? 1) switch-case 2) for 3) if 4) do-while 5) while
2012-04-24, 2956👍, 0💬

What is the difference between a copy constructor and an overloaded assignment operator?
What is the difference between a copy constructor and an overloaded assignment operator? A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.
2012-03-16, 2950👍, 0💬

Will the following program execute? C++
Will the following program execute? C++ Will the following program execute? void main() { void *vptr = (void *) malloc(sizeof(void)); vptr++; } Answer1 It will throw an error, as arithmetic operations cannot be performed on void pointers. Answer2 It will not build as sizeof cannot be applied to void...
2012-03-23, 2936👍, 0💬

< 1 2 3 4 5 6 7 > >>   Sort: Date