Last active
August 29, 2015 14:13
-
-
Save lab101/70b053a0027c663c5d7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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