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 |
What is the difference between Char a[ ]=”string” and char *a=”String”
What is a dll entry point?
In java a final class is a class that cannot be derived. How can you make a similar class in C++
string somestring ; Which of the following choices will convert a standard C++ string object "somestring" to a C string? a) Copy.somestring () ; b) somestring.c_str () c) &somestring [1] d) std::cstring (somestring) e) (char *) somestring
What is split a string in c++?
Should a constructor be public or private?
Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.
Write a program to get the value of sin (x) using a library function , when x is given in degrees.
What does extern mean in a function declaration in c++?
What is a class template in c++?
What are formatting flags in ios class?
Should I learn c or c++ or c#?