Files
2023-06-02 00:03:58 +08:00

42 lines
584 B
C++

#include <iostream>
using namespace std;
class test {
private:
int num;
float fl;
public:
test();
int getint() {
return num;
}
float getfloat() {
return fl;
}
~test();
};
test::test() {
cout << "Initializing default" << endl;
num = 0;
fl = 0.0;
}
test::~test() {
cout << "Destructor is active" << endl;
}
int main() {
test array[2];
cout << array[1].getint() << "" << array[1].getfloat() << endl;
return 0;
};
/*
Initializing default
Initializing default
00
Destructor is active
Destructor is active
*/