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 the uses oof nested class?

0 Answers  


Is c the same as c++?

0 Answers  


How does work in c++?

0 Answers  


What is an html tag?

0 Answers  


What are register variables?

0 Answers  


Where can I run c++ program?

0 Answers  


Differentiate between a template class and class template?

1 Answers  


What are the sizes and ranges of the basic c++ data types?

0 Answers  


Define friend function.

0 Answers  


What are friend functions?

1 Answers  


What is a mutex and a critical section.Whats difference between them?How do each of them work?

4 Answers   CTS,


What is the history of c++?

0 Answers  


Categories