0

C++ Fill in the blanks to define a destructor for class ''MyClass'', which prints some text in its body on the screen.

Fill in the blanks to define a destructor for class ''MyClass'', which prints some text in its body on the screen. MyClass::---------------- { ------------ ---------------------- "some text"; }

29th Dec 2016, 4:05 PM
Anees Hassan
Anees Hassan - avatar
6 Réponses
+ 1
#include <iostream> using namespace std; class AnyClass { int counter; public: AnyClass(int objectId) { counter = objectId; } ~AnyClass() { cout<<"prints destructor for object: "<<counter<<endl; } }; int main() { AnyClass object_0(0); AnyClass object_1(1); AnyClass object_2(2); return 0; } OUTPUT prints destructor for object: 2 prints destructor for object: 1 prints destructor for object: 0
29th Dec 2016, 7:27 PM
Anna Papachristou
Anna Papachristou - avatar
+ 1
~MyClass() cout <<
10th Dec 2019, 2:23 AM
Cyron Cuneta
Cyron Cuneta - avatar
0
Hope this helps
10th Dec 2019, 2:23 AM
Cyron Cuneta
Cyron Cuneta - avatar
0
I Love You. Are you like me ? Cyron Cuneta
13th Jan 2020, 11:25 AM
Imanuel Wicaksono
Imanuel Wicaksono - avatar
0
~myclass cout <<
25th Jul 2020, 11:17 AM
Sara Zuhair Khudher
Sara Zuhair Khudher - avatar
0
Drag and drop from the options below to define a destructor for class ''MyClass'', which prints some text in its body on the screen. Answer: MyClass:: ~MyClass() { cout << "some text"; }
17th Sep 2020, 7:47 PM
OjeifoIduma