Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

Problems with managed classes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ewpatton@gmail.com - 05 Jun 2007 13:15 GMT
I've got two classes, ObjClass1 and ObjClass2. I need them to both
know about one another but I can't include the header twice because of
a "type redefinition" even though it's the same file. Ex:

-----ObjClass1.h-----

#ifndef __OBJCLASS1
#define __OBJCLASS1

#include "ObjClass2.h"

public ref class ObjClass1
{
// Stuff
ObjClass2 ^obj2;
};

#endif

-----ObjClass2.h-----

#ifndef __OBJCLASS2
#define __OBJCLASS2

#include "ObjClass1.h"

public ref class ObjClass2
{
// Stuff
ObjClass1 ^obj1;
};

#endif

Now, with this configuration the compiler just complains that there's
no type ObjClass1 and ObjClass2 for the opposite's header file. So I
tried to undef __OBJCLASS1 in ObjClass2.h to try to fix that problem,
but then it says that I'm redefining ObjClass1 since ObjClass1's
header includes ObjClass2.h which includes ObjClass1 again.

At this point I figured I would just put a forward declaration in each
header:

ref class ObjClass1;

ref class ObjClass2;

But when I do this and try to call a function in the object, the
compiler complains that it has no clue what ObjClass1 and ObjClass2
are.

I'm getting really frustrated by this. Is there any way to fix it?

Evan
ewpatton@gmail.com - 05 Jun 2007 13:45 GMT
On Jun 5, 8:15 am, ewpat...@gmail.com wrote:
> I've got two classes, ObjClass1 and ObjClass2. I need them to both
> know about one another but I can't include the header twice because of
[quoted text clipped - 52 lines]
>
> Evan

Never mind I finally stumbled upon the solution

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.