In C++ ,most of developers are using pimpl idiom or opaque pointers to hide the private data/implementation from the public API, for an example :
- => first case ## Opaque Pointer and PIMPL idiom ##
// in header file
class Node;
class Graph {
public:
A();
private:
Node* m_nodeImpl;
}
// class Node will be defined in respective cpp
2. => second case ## Inner class / Nested class approach ##
// in header file
class Graph {
public:
Graph(){};
private:
class Node
{
// implementation goes here
}
Node* m_nodeImpl;
}
Question is ...
- What is the actual difference between these two approached in perspective of class design (design patterns may be)?
- What are the advantages and disadvantages on each over each?