Skip to content

Instantly share code, notes, and snippets.

@lab101
Last active August 29, 2015 14:13
Show Gist options
  • Save lab101/70b053a0027c663c5d7b to your computer and use it in GitHub Desktop.
Save lab101/70b053a0027c663c5d7b to your computer and use it in GitHub Desktop.
//
// main.cpp
// templatetest
//
// Created by Kris Meeusen on 21/01/15.
// Copyright (c) 2015 Kris Meeusen. All rights reserved.
//
#include <iostream>
class StringResult{
public:
std::string result;
void processUrlFromString(std::string data){
result = data;
}
};
class IntResult{
public:
int result;
void processUrlFromString(std::string data){
result = 10101;
}
};
class UrlLoader{
public:
template<class T>
void loadUrl(T& b){
std::string dataFromTheWeb = "data from thew web";
b.processUrlFromString(dataFromTheWeb);
}
};
int main(int argc, const char * argv[])
{
UrlLoader p;
StringResult r;
p.loadUrl(r);
std::cout << r.result << "\n";
IntResult rInt;
p.loadUrl(rInt);
std::cout << rInt.result << "\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment