1 2 3 4 5 6 > >>   Sort: Rank

How many ways are there to initialize an int with a constant?
How many ways are there to initialize an int with a constant? Two. There are two formats for initializers in C++ as shown in the example that follows. The first format uses the traditional C notation. The second format uses constructor notation. int foo = 123; int bar (123);
2023-12-13, 4730👍, 1💬

💬 2023-12-13 kamalesh: thank you

Which one of the following statements is TRUE in regard to overloading the ++ operator?
Which one of the following statements is TRUE in regard to overloading the ++ operator? 1 You cannot define a post-increment operator. 2 You cannot define a pre-increment operator 3 You cannot define both a pre-increment and post increment operator for a class. 4 You must use a dummy parameter to de...
2018-01-10, 8387👍, 1💬

Should BasketOfApples derive from BasketOfFruit? Why or why not?
Given the following classes class Fruit { // … } class Apple : public Fruit { // … } class Peach : public Fruit { // … } // Container of fruit class BasketOfFruit { BasketOfFruit() ; void insert( Fruit & f ) ; // … } // Container of apples class BasketOfApples /* ??? */ { // … } Should BasketO...
2012-05-14, 3402👍, 0💬

In the H file you see the following declaration
In the H file you see the following declaration: class Foo { void Bar( void ) const ; }; Tell me all you know about the Bar() function.
2012-05-14, 3608👍, 0💬

What does the following code do and why would anyone write something like that?
What does the following code do and why would anyone write something like that? void send (int *to, int * from, int count) { int n = (count + 7) / 8; switch ( count % 8) { case 0: do { *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++...
2012-05-11, 3815👍, 0💬

What’s potentially wrong with the following code?
What’s potentially wrong with the following code? long value; //some stuff value &= 0xFFFF; Note: Hint to the candidate about the base platform they’re developing for. If the person still doesn’t find anything wrong with the code, they are not experienced with C++.
2012-05-11, 3501👍, 0💬

Explain virtual inheritance.
Explain virtual inheritance. Draw the diagram explaining the initialization of the base class when virtual inheritance is used. Note: Typical mistake for applicant is to draw an inheritance diagram, where a single base class is inherited with virtual methods. Explain to the candidate that this is no...
2012-05-10, 3854👍, 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, 3331👍, 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, 3289👍, 0💬

Consider the following struct declarations:
Consider the following struct declarations: struct A { A(){ cout << "A"; } }; struct B { B(){ cout << "B"; } }; struct C { C(){ cout << "C"; } }; struct D { D(){ cout << "D"; } }; struct E : D { E(){ cout << "E"; } }; struct F : A...
2012-05-09, 3320👍, 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, 3260👍, 0💬

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, 3354👍, 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, 3303👍, 0💬

Referring to the sample code above, which one of the following statements is correct?
class A { public: A() { if(x > 1) throw "x overflow"; else x++; } private: static int x; }; int A::x; Referring to the sample code above, which one of the following statements is correct? 1 The class can be instantiated without throwing an exception two times. 2 It cannot be determined how many time...
2012-05-07, 4671👍, 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, 3170👍, 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, 3009👍, 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, 3065👍, 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, 2977👍, 0💬

What will the above code output if strVec is ...
std::cout &lt;&lt; count_if( strVec.begin(), strVec.end(), bind2nd(greater (), "Baz") ); What will the above code output if strVec is a std::vector&lt;std::string >and contains the strings "Foo", "Bar," "Baz", and "Bee"? 1 Unknown, those functions are non-standard. 2 2 3 "Bee" 4 "Baz" 5 ...
2012-05-02, 4019👍, 0💬

Referring to the sample code above, what value does I contain?
char s[] = {'a','b','c',0,'d','e','f',0}; int I = sizeof(s); Referring to the sample code above, what value does I contain? 1 3 2 6 3 7 4 8 5 9
2012-05-02, 3402👍, 0💬

Referring to the sample code above, how do you declare a numbers object called "A" and assign its "I" member the value "2"?
class numbers { int I; public: void set(int v) {I = v;} int read() {return I;} } ; Referring to the sample code above, how do you declare a numbers object called "A" and assign its "I" member the value "2"? 1) A : numbers; A.set(2); 2) numbers set(2); numbers A; 3) numbers A; set(2); 4) A.set(2), B....
2012-05-01, 3363👍, 0💬

Which set of preprocessor directives is used to prevent multiple inclusions of header files?
Which set of preprocessor directives is used to prevent multiple inclusions of header files? 1 #ifndef, #define and #endif 2 #ifdefined and #enddefine 3 #define and #endif only 4 #$if and #endif 5 #if and #define
2012-04-30, 5196👍, 0💬

Referring to the sample code above, which one of the numbered lines of code is legal C++?
class Foo { int i; public: Foo(int x) : i(x) { } }; 1: Foo *f = new Foo; 2: Foo &f = new Foo(1); 3: int i = Foo::i; 4: Foo *af = new Foo[10]; 5: const Foo &af = Foo(1); Referring to the sample code above, which one of the numbered lines of code is legal C++? 1) Line 1 2) Line 2 3) Line 3 4) ...
2012-04-27, 4433👍, 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, 3062👍, 0💬

1 2 3 4 5 6 > >>   Sort: Rank