Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- C++:
- #include <cassert>
- #include <string>
- #include <iostream>
- using namespace std;
- struct lim {
- const double min = -10, max = 10;
- double val;
- lim(double v) {
- assert(v >= min && v <= max);
- val = v;
- }
- lim& operator=(double v) {
- assert(v >= min && v <= max);
- val = v;
- }
- operator double() const {
- return val;
- }
- };
- struct point {
- lim x,y;
- point(double _x, double _y)
- : x(_x), y(_y) { }
- };
- ostream& operator<<(ostream& s, const point& p) {
- s << "[" << + p.x << "," << p.y << "]";
- return s;
- }
- int
- main() {
- point p(5,3);
- cout << p << endl;
- p.y = 17.3;
- cout << p << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement