Advertisement

Prototyping classes?

Started by October 13, 2000 04:18 PM
1 comment, last by MadZorg 24 years, 3 months ago
Alright, i know it is possible to prototype classes. Lets say i have to following code:

//ClassA.h
class CClassB; // class prototype

class CClassA
{
    CClassB* lpClassB;
};

//ClassB.h
class CClassA; // class prototype

class CClassB
{
    CClassA* lpClassA;
}
 
Is is okay to prototype classes this way or should i never do it? Currently i am making wrapper classes for DirectDraw, to make life easier, but i have a problem. I have a class called CGfxSurface and one called CGfxDisplay. CGfxSurface has a pointer to CGfxDisplay and vice versa. The only way around this is using class prototyping (at least that''s the only way i can get around it). Does this mean the code is badly structured? Thanks... -René
It''s up to you. If you feel that it convolutes the code too much (when you prototype), then change it so you don''t need to. If you''re okay with how it works, don''t worry about it.

-Goku
Advertisement
I''m sure there might a way to go about it without having to use prototypes, but your situation is exactly why prototyping exists, so I wouldn''t say your code is badly structured. Some might, but that''s a matter of style .You just can''t avoid it certain situations.
<span class="smallfont">That is not dead which can eternal lieAnd with strange aeons even death may die.   -- "The Nameless City" - H. P. Lovecraft</span>

This topic is closed to new replies.

Advertisement