what is use to destroy an object? illustrate.

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


Please Help Members By Posting Answers For Below Questions

#include #include #include #include void insert(char *items, int count); int main(void) { char s[255]; printf("Enter a string:"); gets(s); insert(s, strlen(s)); printf("The sorted string is: %s.\n", s); getch(); return 0; } void insert(char *items, int count) { register int a, b; char t; for(a=1; a < count; ++a) { t = items[a]; for(b=a-1; (b >= 0) && (t < items[b]); b--) items[b+1] = items[b]; items[b+1] = t; } } design an algorithm for Insertion Sort

2169


why reinterpret cast is considered dangerous?

1903


How is polymorphism achieved?

587


What is polymorphism what is it for and how is it used?

576


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?

1395






What are the types of abstraction?

558


Can a destructor be called directly?

603


What is oops with example?

566


What is the use of oops?

623


Please send ford technologies placement paper 2 my mail id

1658


What is encapsulation in oop?

609


What is this pointer in oop?

557


Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.

2008


What does <> mean pseudocode?

624


What is the problem with multiple inheritance?

586