Created
November 25, 2012 18:50
-
-
Save jatinganhotra/4144783 to your computer and use it in GitHub Desktop.
Use forward declarations in C++ in all the following cases:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Master { | |
private: | |
// Declare a member to be a pointer or a reference to the incomplete type | |
Forward *ptr1; | |
Forward &ptr2; | |
public: | |
// Declare functions or methods which accepts/return incomplete types: | |
void ByValue(Forward by_value); | |
Forward OrReturnValue(); | |
// Define functions or methods which accepts/return pointers/references | |
// to the incomplete type (but without using its members): | |
void OrByPointer(Forward* by_pointer); | |
void OrByReference(const Forward& by_reference); | |
Forward& ReturnByRef(); | |
Forward* ReturnByPointer(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment