Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2370 views
1
//use an alternate syntax to put things into our namespace
2
// This method is preferred by most programmers
3
#include <iostream>
4
#include "ns2.h"
5
6
void
7
ns2::f()
8
{
9
std::cout << "ns2 function f" << std::endl;
10
}
11
12
13
ns2::Example::Example()
14
{
15
//initialize our object
16
x1 = x2 = 1;
17
}
18
19
20
void
21
ns2::Example::f()
22
{
23
int result = x1+x2;
24
25
std::cout << "Num: " << result << std::endl;
26
27
//do some shifting
28
x2=x1;
29
x1=result;
30
}
31