Question: Very new to c++ having trouble calling a function from another class.

Class B inherits from Class A, and I want class A to be able to call a function created in class B.

```
using namespace std;

class B;

class A 
{

public:

    void CallFunction ()
    {
        B b;
        b.bFunction();
    }

};

class B: public A
{
public:
    virtual void bFunction()
        {
            //stuff done here
        }

};

```

It all looks fine on screen (no obvious errors) but when I try to compile it i get an error C2079 'b' uses undefined class B.

I've tried making them pointers/ `friends` but I'm getting the same error.

Answer: 
class B is only **declared** but not **defined** at the beginning, which is what the compiler complains about. The root cause is that in class A's Call Function, you are referencing instance b of type `B`, which is incomplete and undefined. You can modify source like this without introducing new file(just for sake of simplicity, not recommended in practice):

```
using namespace std;

class A 
{
public:

    void CallFunction ();
};

class B: public A
{
public:
    virtual void bFunction()
    {
        //stuff done here
    }
};

 // postpone definition of CallFunction here

 void A::CallFunction ()
 {
     B b;
     b.bFunction();
 }

```
in A you have used a definition of B which is not given until then , that's why the compiler is giving error .