13年题。

This commit is contained in:
unlockable
2023-06-02 00:03:58 +08:00
parent 955977fef2
commit 9cecf352c2
11 changed files with 401 additions and 0 deletions

42
OOP/13Exam/3.1.cpp Normal file
View File

@@ -0,0 +1,42 @@
#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
*/