# function ptr using class currently being defined.

This topic is 4845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm having problems getting two classes to get along. Basically each one needs the other in their headers. I am using #pragma once to avoid the natural redefinition errors, but that's not the problem (or at least I don't think it is). (The actual code is fairly large, I'm doing my own GUI library as a learning exercise.) The basic idea is:
#pragma once
#include "B.h"

typedef void (*FUNPTR)(B*);

class A
{
private:
FUNPTR p;
};
-------
#pragma once
#include "A.h"

class B
{
public:
/* stuff */
A an_a;
};
The error I get is "C2460: 'A::FUNPTR' : uses 'A' which is being defined." which doesn't make any sense. Can someone help me with this? Thanks in advance :)

##### Share on other sites
A doesn't need B.

#pragma onceclass B;typedef void (*FUNPTR)(B*);class A{private:      FUNPTR p;};

-------

#pragma once#include "A.h"class B{public:    /* stuff */    A an_a;};

##### Share on other sites
dangit! I could have sworn I tried that already...

Oh, well.. it works now. Thanks.

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633271
• Total Posts
3011161
• ### Who's Online (See full list)

There are no registered users currently online

×