Created
July 23, 2013 05:53
-
-
Save uhziel/6060143 to your computer and use it in GitHub Desktop.
测试“形参为对象时的默认参数”
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| class Foo { | |
| public: | |
| Foo() : a(0) {} | |
| public: | |
| int a; | |
| }; | |
| void myprint(const Foo& foo = Foo()) { | |
| std::cout << foo.a << std::endl; | |
| } | |
| int main() { | |
| Foo foo; | |
| foo.a = 2; | |
| myprint(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment