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

What are containers in c++?

0 Answers  


Which bit wise operator is suitable for checking whether a particular bit is on or off?

0 Answers  


Explain what data encapsulation is in c++?

0 Answers  


What are c++ tokens?

0 Answers  


What is an accessor in c++?

0 Answers  






why the size of an empty class is 1

4 Answers  


Write a Program for find and replace a character in a string.

0 Answers  


What does namespace mean in c++?

0 Answers  


Explain binary search.

0 Answers  


sir i want to study the c++ course but ino what is the qualification and the study methode please reply more details in c++

1 Answers   NIIT,


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

4 Answers   CTS,


What are the defining traits of an object-oriented language?

0 Answers  


Categories