How many ways are there to initialize an int with a constant?
Answer Posted / 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 View All Answers
What is the iunknown interface?
What is the array and initializing arrays in c++?
What is void pointer in c++ with example?
Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .
Define a pointer to a data member of the type pointer to pointer?
What is abstract class in c++?
When does a name clash occur in c++?
Will a recursive function without an end condition every quit, in practice a) Compiler-Specific (Some can convert to an infinite loop) b) No c) Yes
What is a singleton c++?
Can we run c program in turbo c++?
How does a C++ structure differ from a C++ class?
What is the protected keyword used for?
What do you mean by funtion prototype?
Why was c++ created?
What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor