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



class CTest { public: void someMethod() { int nCount = 0; cout << "..

Answer / Hirawan Lal

In this code, you are defining a class named CTest and its method someMethod. However, to execute the someMethod() and display its output, you need to create an object of the class CTest. This can be done using the 'new' keyword followed by the class name. For example: CTest pctest(new CTest()); pctest.someMethod();

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More OOPS Interview Questions

what i oops concept, how many languages supports oops concept?

3 Answers   Value Labs,


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

1 Answers  


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!!!)

1 Answers   HCL,


Definition of Object Oriented Programming in single line?

33 Answers   Impact Systems, Q3 Technologies, TCS,


how do u initialize the constant variables

5 Answers   IBM, Siemens,


what's the basic's in dot net

1 Answers   informatics,


How does polymorphism work?

1 Answers  


Advantage and disadvantage of routing in telecom sector

1 Answers  


What do you mean by variable?

1 Answers  


Why a "operator=(...)" when there is a copy ctor?

2 Answers  


officer say me - i am offered to a smoking , then what can you say

1 Answers  


What are virtual classes?

0 Answers  


Categories