How many ways are there to initialize an int with a constant?
Answer Posted / 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 |
Post New Answer View All Answers
What kind of problems can be solved by a namespace?
When does the c++ compiler create temporary variables?
How the delete operator differs from the delete[]operator?
What are the characteristics of friend functions?
Explain function overloading and operator overloading.
Why are pointers used?
Do we have to use initialization list in spite of the assignment in constructors?
Why is standard template library used?
Describe the role of the c++ in the tradeoff of safety vs. Usability?
Do vectors start at 0?
What do you mean by translation unit?
Describe new operator?
Do you know what are static and dynamic type checking?
Incase of a function declaration, what is extern means?
What is static class data?