How many ways are there to initialize an int with a constant?



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

Post New Answer

More C++ General Interview Questions

Can comments be longer than one line?

0 Answers  


Can union be self referenced?

0 Answers  


What is singleton pattern in c++?

0 Answers  


How to implement flags?

2 Answers   Symphony,


Which function cannot be overloaded c++?

0 Answers  






Is c++ an oop?

0 Answers  


What are formatting flags in ios class?

0 Answers  


Search for: what is pair in c++?

0 Answers  


How can you specify a class in C++?

0 Answers  


What is RTRT tool?can it be used for automation?can it work on packet PC?

3 Answers  


What is :: operator in c++?

0 Answers  


How do you write a function that can reverse a linked-list?

0 Answers  


Categories