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"; }
6 Antworten
+ 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
+ 1
~MyClass()
cout
<<
0
Hope this helps
0
I Love You. Are you like me ?
Cyron Cuneta
0
~myclass
cout
<<
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";
}