Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-----------'Optimized' version
- #include <iostream>
- class Thing {
- public:
- int getX() const;
- void setX(const int x);
- private:
- int x;
- };
- inline int Thing::getX() const {
- return x;
- }
- inline void Thing::setX(const int x) {
- this->x = x;
- }
- inline void printMe(const Thing& thing) {
- std::cout << thing.getX() << "\n";
- }
- int main() {
- Thing thing;
- thing.setX(123);
- printMe(thing);
- }
- //-------------Lazy programmer
- #include <iostream>
- class Thing {
- public:
- int getX() ;
- void setX(int x);
- private:
- int x;
- };
- inline int Thing::getX() {
- return x;
- }
- inline void Thing::setX(int x) {
- this->x = x;
- }
- inline void printMe(Thing thing) {
- std::cout << thing.getX() << "\n";
- }
- int main() {
- Thing thing;
- thing.setX(123);
- printMe(thing);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement