The code is working in that it couts haha but it causes an error because it says:
Process returned -1073741819 <0xC0000005>
And a window pops up telling me if I would like to send an error message. Why is this?
#include <iostream>
using namespace std;
template <class A>
A print( A a ) {
cout << a;
}
template <class T>
class David {
T a;
public:
David( T something ) : a( something ) {}
void laugh() {
print(a);
}
};
int main() {
David <string> Do("Hahaha");
Do.laugh();
}
It`s incorrect. No return value in function, so, compiler returns some garbage from stack.
And better i think will be this declaration