forward declaration of class from another namespace

S

Sergey Lukoshkin

Hello, dear community!

I've faced such a problem:

1. I got header "headerA.h" with the following code:

----------------------------------------
#include "headerB.h"

namespace A
{
class A
{
public:

create_b_ojects()
{
B* pB = new B( this );
}
};
}

-------------------------------------

2. And I got header "headerB.h" with the following code:
-------------------------------------------
namespace B
{

class B
{
public:
B(){}
B( /* here I need to use pointer to object of type A::A
*/ ){....}
};

}
 
V

Vladimir Jovic

Sergey said:
Hello, dear community!

I've faced such a problem:

1. I got header "headerA.h" with the following code:

----------------------------------------
#include "headerB.h"

namespace A
{
class A
{
public:

create_b_ojects()
{
B* pB = new B( this );
}
};
}

-------------------------------------

2. And I got header "headerB.h" with the following code:
-------------------------------------------
namespace B
{

class B
{
public:
B(){}
B( /* here I need to use pointer to object of type A::A
*/ ){....}
};

}

Add this to headerB.h :
namespace A
{
class A;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top