What do i have to do to this code to make it compile, it's braking around this line:
auto val = what.getObject();
#include<iostream>
using namespace std;
class CUP{
public:
void whatsHappening(){}
};
class MUG{
public:
void whatsHappening(){}
};
class CupThrower{
public:
CUP cp;
CUP getObject(){ return cp;}
};
class MugThrower{
public:
MUG mg;
MUG getObject(){return mg;}
};
template <typename T> void whatsHappening(T what){
auto val = what.getObject(); //DOES NOT COMPILE
val.whatsHappening();
}
int main(){
CupThrower ct;
MugThrower mt;
whatsHappening(ct);
whatsHappening(mt);
return 0;
}
i am using VS2008 to compile.