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

INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?

0 Answers  


What is the real time example of encapsulation?

0 Answers  


class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash

0 Answers  


Can we have inheritance without polymorphism?

0 Answers  


What do you mean by stack program? Get me an example stack program?

4 Answers  


who is the founder of c++?

15 Answers   Hexaware, ONGC,


What is the different between Applet and Application?

2 Answers  


what is the sylabus for priliminaries?

0 Answers  


How to use CMutex, CSemaphore in VC++ MFC

0 Answers   Persistent, TCS,


difference between structure and union.

2 Answers   ADP, Convergys,


What is function overloading?,describe it with the example.

5 Answers  


Why multiple inheritance is not allowed?

0 Answers  


Categories