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

Explain how to initialize a const member data.

0 Answers  


5. Can inline functions have a recursion?

4 Answers  


Why can templates only be implemented in the header file?

0 Answers  


What does #define mean in c++?

0 Answers  


How do you invoke a base member function from a derived class in which you have not overridden that function?

0 Answers  






How did c++ start?

0 Answers  


What are the advantages and disadvantages of using inline and const?

2 Answers   Polaris, TCS, Zimmer Biomet,


Describe the setting up of my member functions to avoid overriding by the derived class?

0 Answers  


What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal

0 Answers  


What is a manipulative person?

0 Answers  


how many trys can we write in one class

3 Answers   Cap Gemini,


What is the default access level?

0 Answers  


Categories