Skip to content

Instantly share code, notes, and snippets.

@uhziel
Created July 23, 2013 05:53
Show Gist options
  • Select an option

  • Save uhziel/6060143 to your computer and use it in GitHub Desktop.

Select an option

Save uhziel/6060143 to your computer and use it in GitHub Desktop.
测试“形参为对象时的默认参数”
#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