
Untitled
By: a guest on
Oct 2nd, 2011 | syntax:
C++ | size: 0.85 KB | hits: 48 | expires: Never
//-----------'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);
}