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


Please Help Members By Posting Answers For Below Questions

Write a function to find the nth item from the end of a linked list in a single pass.

653


Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---

1748


Explain the problem with overriding functions

679


What does std mean in c++?

694


List the special characteristics of constructor.

832






Is it possible to provide default values while overloading a binary operator?

867


What is the difference between object-oriented programming and procedural programming?

788


Is c++ fully object oriented?

641


Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

697


How is c++ different from java?

671


How do I use turbo c++?

623


There are 100 students in a class. The management keep information in two tables. Those two tables are given like Roll no Name Age 001 ABC 15 002 XYZ 14 and Roll No Subject Marks 001 Math 75 001 Physics 55 002 Math 68 001 Hindi 69 They want the information like this Roll No Name Hindi Physics Math Total 001 ABC 69 55 75 199 002 XYZ 68 74 84 226 And Roll No Suject Highest 001 Math 98 007 Physics 84 021 Hindi 74 All 275 All information is kept in structure in main memory. You have to find last two tables.

2618


Does c++ have a hash table?

654


Is c the same as c++?

650


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

738