how do u initialize the constant variables

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the importance of oop?

613


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

1702


What is stream in oop?

841


What does no cap mean?

592


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

1643






What is multilevel inheritance in oop?

557


What are oops functions?

585


What is a class and object?

600


What is overloading and its types?

618


What is the difference between abstraction and polymorphism?

619


Which method cannot be overridden?

584


What are two types of polymorphism?

614


write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.

1795


What is the difference between inheritance and polymorphism?

594


What is the main purpose of inheritance law?

673