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
Does c++ support multilevel and multiple inheritances?
How would you use the functions randomize() and random()?
What are the c++ access specifiers?
What is the full name of logo?
Explain the operation of overloading of an assignment operator.
What are the advantages of using pointers in a program?
What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0
How should runtime errors be handled in c++?
Difference between inline functions and macros?
Differentiate between declaration and definition.
Please explain the reference variable in c++?
Is swift faster than c++?
If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?
Explain what are single and multiple inheritances in c++?
When should I use unitbuf flag?