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

You’re given a simple code for the class BankCustomer. Write the following function
You’re given a simple code for the class BankCustomer. Write the following functions: * Copy constructor * = operator overload * == operator overload * + operator overload (customers’ balances should be added up, as an example of joint account between husband and wife) Note:Anyone confusing assignme...
2012-05-08, 3469👍, 0💬

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, 3442👍, 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, 3428👍, 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, 3427👍, 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, 3409👍, 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, 3388👍, 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, 3329👍, 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, 3278👍, 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, 3274👍, 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, 3267👍, 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, 3230👍, 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, 3202👍, 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, 3189👍, 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, 3181👍, 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, 3165👍, 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, 3139👍, 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, 3100👍, 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, 3094👍, 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, 3080👍, 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, 3079👍, 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, 3059👍, 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, 3055👍, 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, 3051👍, 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, 3047👍, 0💬

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