how do u initialize the constant variables

Answers were Sorted based on User's Feedback



how do u initialize the constant variables..

Answer / subu

const int pp = 100;

Is This Answer Correct ?    8 Yes 1 No

how do u initialize the constant variables..

Answer / sachin

In Constructor Initialization list

Is This Answer Correct ?    9 Yes 3 No

how do u initialize the constant variables..

Answer / keshav.gadde

class sam
{
const int x;
public:
sam(int i):x(i)
{
cout<<i<<endl;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
sam s(10);
return 0;
}

Is This Answer Correct ?    4 Yes 0 No

how do u initialize the constant variables..

Answer / bibin joy

class A
{
const int mConstVal ;
A():mConstVal (10)
{

}

}

Is This Answer Correct ?    4 Yes 1 No

how do u initialize the constant variables..

Answer / yughandhar

as for my knowledge,the constant variables are intialised by
keyword called DEFINE
Eg:
#define pie=3.14

Is This Answer Correct ?    4 Yes 7 No

Post New Answer

More OOPS Interview Questions

The company is a fake company asking for money of RS10000 while training and not offering a job after training. My humble request to you people not to attend Astersys interview

1 Answers   Astersys,


Why many objects can working together? How objects working togetherM I want to see example code.

2 Answers  


What is use of overloading?

0 Answers  


write knight tour problem which is present in datastructure

0 Answers  


What is class and example?

0 Answers  






How do you define social class?

0 Answers  


define a string class. overload the operator == to compare two strings

2 Answers   Birla, Ericsson, HCL, Infosys, Infotech, MCAS, Satyam,


string is a class or data type in java?

3 Answers  


What is a template?

7 Answers  


what is the use of template classes in c++

1 Answers  


What is solid in oops?

0 Answers  


Explain polymorphism? What r the types of polymorphism? pls give examples?

4 Answers   HCL,


Categories