Owlglass

C++ Programming

Basics

Hello world

1
2
3
4
5
#include <iostream>

int main(){
    std::cout << "Hello, world." << std::endl;
}

Templates

Basic Template

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <iostream>

template<typename T>
T add_em_up(T& lhs, T& rhs){
    return lhs + rhs;
    }

int main(){

    int a{ 72 };
    int b{ 47 };
    std::cout << add_em_up<int>(a,b) << "\n";
}