13年题。
This commit is contained in:
42
OOP/13Exam/3.1.cpp
Normal file
42
OOP/13Exam/3.1.cpp
Normal 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
|
||||
*/
|
||||
Reference in New Issue
Block a user