Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class MyClass
- {
- private:
- bool done;
- double x;
- double result;
- public:
- MyClass();
- virtual ~MyClass() {}
- void set(double x);
- void print();
- void run();
- };
- MyClass::MyClass()
- {
- this->x = 0;
- this->done = false;
- }
- void MyClass::set(double x)
- {
- this->x = x;
- }
- void MyClass::print()
- {
- if (this->done) {
- std::cout << "Result: " << this->result << std::endl;
- } else {
- std::cout << "First execute method run();" << std::endl;
- }
- }
- void MyClass::run()
- {
- this->result = (this->x + 100) / 10;
- this->done = true;
- }
- int main()
- {
- MyClass myClass;
- myClass.set(10);
- myClass.run();
- myClass.print();
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement