Answer Posted / sujatha
object can be destroyed by using DESTRUCTORS
EX:
class A
{
int p;
public:
A(int x)
{
x=p;
cout<<"constructor is called memory is allocated to
variable x\n";
}
void show()
{
cout<<"x="<<x;
}
~A()
{
cout<<"destructor called and deaalocte memory occupied by
x\n";
}
};
void main()
{
A a1(10);
a1.show();
}
output
constructor called memory is allocated to variable x
x=10
destructor called and deaalocte memory occupied by x
Is This Answer Correct ? | 9 Yes | 0 No |
Post New Answer View All Answers
#include
why reinterpret cast is considered dangerous?
How is polymorphism achieved?
What is polymorphism what is it for and how is it used?
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?
What are the types of abstraction?
Can a destructor be called directly?
What is oops with example?
What is the use of oops?
Please send ford technologies placement paper 2 my mail id
What is encapsulation in oop?
What is this pointer in oop?
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
What does <> mean pseudocode?
What is the problem with multiple inheritance?