Imagine this simple code, why does it get compile error?
#include <iostream>
using namespace std;
class foo{
public:
int *b;
foo(int a) {
b = NULL;
}
};
void bar(foo *&a) {
cout << "OK?" << endl;
}
int main() {
foo a(2);
bar(&a);
return 0;
}
I know I can use bar(foo *a)
but why with & symbol it doesn't work and how can I make it work?