Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2370 views
1
#include <iostream>
2
3
//define a namespace called ns1
4
namespace ns1
5
{
6
void f() {
7
std::cout << "ns1 function f" << std::endl;
8
}
9
}
10
11
12
//define a namespace called ns2
13
namespace ns2
14
{
15
void f() {
16
std::cout << "ns2 function f" << std::endl;
17
}
18
}
19
20
21
int main()
22
{
23
//call our functions within the two namespaces
24
ns1::f();
25
ns2::f();
26
27
return 0;
28
}
29