CSC112 Spring 2016 Examples
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 6void 7ns2::f() 8{ 9 std::cout << "ns2 function f" << std::endl; 10} 11 12 13ns2::Example::Example() 14{ 15 //initialize our object 16 x1 = x2 = 1; 17} 18 19 20void 21ns2::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