Home | 11 ஆம் வகுப்பு | 11வது கணினி அறிவியல் | C++: அறிவிப்பு மற்றும் வரையறுப்பு

C++ இல் உள்ள எடுத்துக்காட்டு நிரல்கள் - C++: அறிவிப்பு மற்றும் வரையறுப்பு | 11th Computer Science : Chapter 14 : Classes and objects

11வது கணினி அறிவியல் : அலகு 14 : இனக்குழுக்கள் மற்றும் பொருள்கள்

C++: அறிவிப்பு மற்றும் வரையறுப்பு

அழிப்பி என்ற சிறப்பு செயற்கூறானது ஆக்கியால் உருவாக்கப்பட்ட பொருளின் வாழ்நாள் முடிந்து அழியும்போது அழைக்கப்படுகிறது.

அறிவிப்பு மற்றும் வரையறுப்பு


அழிப்பி என்ற சிறப்பு செயற்கூறானது ஆக்கியால் உருவாக்கப்பட்ட பொருளின் வாழ்நாள் முடிந்து அழியும்போது அழைக்கப்படுகிறது. பொதுவாக Public பகுதியில் அறிவிக்கப்படுகிறது.


நிரல் 14.8 அழிப்பி செயற்கூறினை விளக்குகிறது

#include<iostream>

using namespace std;

class simple

{

private:

int a, b;

public:

simple()

{

a= 0 ;

b= 0;

cout<< "\n Constructor of class-simple ";

}

void getdata()

{

cout<<"\n Enter values for a and b (sample data 6 and 7)... ";

cin>>a>>b;

}

void putdata()

{

cout<<"\nThe two integers are .. "<<a<<'\t'<< b<<endl;

cout<<"\n The sum of the variables "<<a<<" + "<<b<<" = "<<a+b;

}

~simple()

{ cout<<”\n Destructor is executed to destroy the object”;} };

int main()

{

simple s;

s.getdata();

s.putdata();

return 0;

}

Output:

Constructor of class-simple

Enter values for a and b (sample data 6 and 7)... 6 7

The two integers are .. 6       7

The sum of the variables 6 + 7 = 13

Destructor is executed to destroy the object


11வது கணினி அறிவியல் : அலகு 14 : இனக்குழுக்கள் மற்றும் பொருள்கள்