int main() { Foo f; std::cout << f.y_ << std::endl; f.setX(2); std::cout << f.y_ << std::endl; return 0; }
int main(int argc, char* argv[]) { { Foo a(9); Foo b = a; // same as Foo b(a); Foo c(5); std::cout << a.toString() << std::endl; std::cout << b.toString() << std::endl; std::cout << c.toString() << std::endl; c = a; std::cout << c.toString() << std::endl; c = c; std::cout << c.toString() << std::endl; std::cout << "Swap test ------------------" << std::endl; b.setX(10); std::cout << a.toString() << " " << b.toString() << std::endl; a.swap(b); std::cout << a.toString() << " " << b.toString() << std::endl; } // scoped to print end of main AFTER objects get destructed std::cout << "::main()" << std::endl; return 0; }
void test() { a.setX(10); }