|
-
November 15th, 2010, 10:02 AM
#1
Class containing struct referencing class
For this problem, it might be simpler to begin with a code extract:
Code:
class Pattern
{
public:
struct ChildPattern
{
Pattern pattern;
int offset;
};
};
Instances of "ChildPattern" are going to be kept in lists and the like, and "offset" is something associated with instances of Pattern but it is not intrinsic to them (i.e. it shouldn't be part of the class, except as a hack).
Anyway the problem is that the above code doesn't compile. I get
Pattern::ChildPattern:: pattern uses undefined class 'Pattern'
.
Any suggestions? I don't want to change the first struct element to "Pattern * pPattern" if I can help it: the class is simple and I don't want to add new() and delete() unnecessarily.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|