-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfoo.cc
45 lines (35 loc) · 988 Bytes
/
foo.cc
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
module;
#include <iostream>
export module foo;
export extern const int LUCKY_NUMBER = 7;
// Forwad declaration of function is not needed
// baceuse e.g. it was not used in cosntrucor in class declaration
// but if also want to hold signatures in one place..
// export int publicFunction(int a, int b);
// Whole class export
export class foo {
public:
foo() = default;
~foo();
void helloworld(int n);
};
// It can not be done in class declaration because of std:: import use
foo::~foo() {
std::cout << "Destructor called \n";
}
// Exporting namespaces also works: hi::english() and hi::french() will be visible.
export namespace hi
{
char const* english() { return "Hello"; }
char const* french() { return "Salut"; }
}
// Method example
void foo::helloworld(int n) {
std::cout << hi::english() << " world " << n << std::endl;
}
int privateFunction(int a, int b) {
return a * b;
}
export int publicFunction(int a, int b) {
return privateFunction(a, b);
}