Skip to content

Instantly share code, notes, and snippets.

View melvyniandrag's full-sized avatar
🌕
A Picture of Jupiter and 4 of its Moons Through Our Telescope.

melvyniandrag

🌕
A Picture of Jupiter and 4 of its Moons Through Our Telescope.
View GitHub Profile
@melvyniandrag
melvyniandrag / main.cpp
Created August 8, 2017 19:45
Template functions in source
#include "t.h"
int main()
{
myClass mc;
mc.f(1);
mc.f("hi");
}
#ifndef BASE_H
#define BASE_H
#include <map>
#include <string>
#include <iostream>
class Base{
public:
const std::map<std::string, std::string>& m;
@melvyniandrag
melvyniandrag / r_val_ref_example.cpp
Created January 21, 2017 15:37
The destructor is called as described in the concrrency tutorial.
#include <iostream>
#include <string>
class BartoszMilewski{
public:
BartoszMilewski(){
greeting = "Hello";
std::cout << greeting << std::endl;
}
~BartoszMilewski(){
@melvyniandrag
melvyniandrag / threads.cpp
Created January 21, 2017 07:01
this code doesnt behave as it does in the video https://www.youtube.com/watch?v=4Udi9iAyVBQ.
/*
Compiled with
g++ -std=c++11 threads.cpp -pthreads
on ubuntu 15.04 with g++ 4.8
My strange output is:
> ./a.out
Hello from main!
Hello from thread 25615440
@melvyniandrag
melvyniandrag / inherited_vector.cpp
Created March 2, 2016 02:10
A little snippet to exercise some C++ skills I dont get to use too often.
/*
* A code sample showing the use of the STL (priority_queue, vector), inheritence from an
* abstract class, templated classes, and templated functors.
* Also, use of c++11 features.
* Also, use of pointers to store inherited elements in a vector of type base_class.
*
* There's alot of interesting C++ stuff in here.
*
* Melvyn Ian Drag ~ 1 March 2015.
* Compile with g++ -std=c++11 -o inherit inherited_vector.cpp