-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionCallEvaluation.cpp
More file actions
55 lines (44 loc) · 905 Bytes
/
functionCallEvaluation.cpp
File metadata and controls
55 lines (44 loc) · 905 Bytes
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
47
48
49
50
51
52
53
54
55
#include<iostream>
#include<thread>
using namespace std;
class A {
public:
A() {}
A(int a) {}
void fn() {}
};
int fn(A obj) {
}
class B {
public:
B(A obj) {}
};
class Functor {
public:
void operator()() {}
};
/*
Expressions that can be evaluated as function definitions will
be considered as function definitions.
*/
int main() {
A obj1();
// will compile but here we are not creating an object obj1
// we are creating a function obj1 which returns A and takes no arguments
// usually a warning is generated for this.
A obj2(1);
// obj1.fn(); // Due to the above mentioned reason, this statement doesn't compile
obj2.fn();
// OK
int a = fn(obj2);
// OK
a = fn(A());
// OK
a = fn(A(2));
// All 3 OK
B obj3(A());
B obj4(A(1));
B obj5(obj2);
// Ok
thread t1(Functor());
}