-
Notifications
You must be signed in to change notification settings - Fork 160
/
function.cpp
46 lines (34 loc) · 935 Bytes
/
function.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// # function
#include "common.hpp"
// Default arguments.
void defaultArgProto(int i=0);
void defaultArgProto(int i) {}
// BAD: usually not what you want
// since includers will not see the default version
void defaultArgDef(int i);
void defaultArgDef(int i=0) {}
// ERROR: default cannot go in declaration and definition
//void defaultArgBoth(int i=0);
//void defaultArgBoth(int i=0) {}
int def_no_argname(int) { return 1; }
int def_no_argname(int, int) { return 2; }
/*
# auto arguments
*/
/*ERROR: no you can't*/
/*
int func_auto(auto a){
++a;
return (int)a;
}
*/
int main() {
/*
In C++, unlike in C, definitions can omit argument names if they don't use those arguments!
This probably exists for method overridding.
*/
{
assert(def_no_argname(0) == 1);
assert(def_no_argname(0, 0) == 2);
}
}