How many ways are there to initialize an int with a constant?
Answer / nikhil upadhyay
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);
It's acceptable when a programmer does not know about the second notation, although they should certainly know about the first one. Many old-timer C programmers who made the switch to C++ never use the second idiom, although some wise heads of C++ profess to prefer it. If your applicant is quick with the right answer, that's a good sign.
| Is This Answer Correct ? | 0 Yes | 0 No |
What are punctuators in c++?
What is a dll entry point?
How is c++ used in the real world?
Can we use this pointer in a class specific, operator-overloading function for new operator?
What do you mean by function pointer?
What are the characteristics of friend functions?
What is prototype in c++ with example?
Why do we need c++?
Tell me an example where stacks are useful?
Evaulate: 22%5 a) 2 b) 4 c) 0
Why ctype h is used in c++?
What are move semantics?