Created
August 19, 2013 00:11
-
-
Save nathan-osman/6264792 to your computer and use it in GitHub Desktop.
Represents a simple class in C++ for storing values of any type.
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
#include <iostream> | |
#include "variant.h" | |
int main(int argc, char * argv[]) | |
{ | |
Variant v; | |
v.setValue(12); | |
std::cout << v.getValue<int>() << std::endl; | |
return 0; | |
} |
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
all: variant | |
variant.o: variant.cpp variant.h value.h | |
g++ -c variant.cpp | |
main.o: main.cpp variant.h value.h | |
g++ -c main.cpp | |
variant: variant.o main.o | |
g++ variant.o main.o -o variant |
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
#ifndef VALUE_H | |
#define VALUE_H | |
class Value | |
{ | |
}; | |
#endif // VALUE_H |
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
#include "variant.h" | |
Variant::Variant() | |
{ | |
} | |
Variant::~Variant() | |
{ | |
} |
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
#ifndef VARIANT_H | |
#define VARIANT_H | |
#include "value.h" | |
class Variant | |
{ | |
public: | |
Variant(); | |
~Variant(); | |
template <typename T> T getValue() const | |
{ | |
} | |
template <typename T> void setValue(const T & value) | |
{ | |
} | |
private: | |
//... | |
}; | |
#endif // VARIANT_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment