Move doSomething
definition outside of its class declaration and after B
and also make add
accessible to A
by public
-ing it or friend
-ing it.
class B;
class A
{
void doSomething(B * b);
};
class B
{
public:
void add() {}
};
void A::doSomething(B * b)
{
b->add();
}
More Related Contents:
- When can I use a forward declaration?
- What are forward declarations in C++?
- Forward declaration of nested types/classes in C++
- How do I forward declare an inner class? [duplicate]
- Forward declaration of a typedef in C++
- Should one use forward declarations instead of includes wherever possible?
- Forward declaration with unique_ptr? [duplicate]
- In C++, is it possible to forward declare a class as inheriting from another class?
- What is the header?
- Why, really, deleting an incomplete type is undefined behaviour?
- What is forward declaration in c++? [duplicate]
- C++ class forward declaration
- Why does a C++ friend class need a forward declaration only in other namespaces?
- forward declaration with vector of class type – pointer to incomplete class type not allowed
- Why must an enumeration’s size be provided when it is forward declared?
- What is the purpose of forward declaration?
- Forward Declaration of variables/classes in std namespace
- C++ Programming ( advantages of by ref & by val) query? / methods of editing struct other than byRef
- undefined reference to `WinMain@16′
- while (1) Vs. for (;;) Is there a speed difference?
- What is the proper OpenGL initialisation on Intel HD 3000?
- Capture screen using DirectX
- Why is std::cout not printing the correct value for my int8_t number?
- Making a template parameter a friend?
- CMake – remove a compile flag for a single translation unit
- Is there an equivalent to WinAPI’s MAX_PATH under linux/unix?
- Do I have to bind a UDP socket in my client program to receive data? (I always get WSAEINVAL)
- How to count lines of a file in C++?
- const auto std::initializer_list difference between Clang and GCC
- C++ function called without object initialization