It might be a C++ beginner mistake but I'm really confused now by getting this compiler Error:
error: no matching function for call to 'B::B(A (*)())'
note: candidates are: B::B(A*)
I have written two class which look simplified like this:
//a very simple class A
class A
{
public:
A()
{
//do some stuff in Constructor
}
}
//another class, that stores a pointer to an object of A as a field
class B
{
private:
A* _a;
public:
//simply initialize the field in Constructor
B(A* a) : _a(a) { }
void doMagic()
{
//do something with _a
_a->xyz();
}
}
And what I am calling in my code is this:
A a();
B b(&a); //here the error appears
What I want is to create an object a and pass its pointer to object b. So that I have access to a in b's members.
It must be just something in the call of B b(&a); Perhaps you can find out what my Problem is very easily.