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 |
Can comments be longer than one line?
Can union be self referenced?
What is singleton pattern in c++?
How to implement flags?
Which function cannot be overloaded c++?
Is c++ an oop?
What are formatting flags in ios class?
Search for: what is pair in c++?
How can you specify a class in C++?
What is RTRT tool?can it be used for automation?can it work on packet PC?
What is :: operator in c++?
How do you write a function that can reverse a linked-list?