Hi guys,
I am a beginner in C++, but I've got to implement as simple a class as possible to pass the test case below:
Code:
#include <iostream>
#include <string>
#include <assert.h>
class cVarCont
{
public:
template <class T>
void manage(const std::string& name, T& varRef)
{
}
public:
void setValue(const std::string& namedVariable, const std::string& value)
{
}
};
int main()
{
cVarCont nvc;
int myInt(0);
double myDouble(0.);
std::string myString("");
nvc.manage("int", myInt);
nvc.manage("dbl", myDouble);
nvc.manage("str", myString);
nvc.setValue("int", "43");
nvc.setValue("dbl", "123.8");
nvc.setValue("str", "hello");
std::cout << myInt << std::endl;
std::cout << myDouble << std::endl;
std::cout << myString << std::endl;
std::cout<<"Hello World\n";
assert(myInt==43);
assert(myDouble==123.8);
assert(myString=="hello");
return 0;
}
And do not use a void pointer.
I appreciate any hints on this.
Thanks.