Closed Thread Icon

Preserved Topic: C++ question (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=17130" title="Pages that link to Preserved Topic: C++ question (Page 1 of 1)" rel="nofollow" >Preserved Topic: C++ question <span class="small">(Page 1 of 1)</span>\

 
Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-24-2002 04:42

I have a Transformation class that uses my Vector class (not to be confused with STL vector) as a private member variable.

My Vector class has a function which takes a Transformation object.

How do I do this? I can't define either one of them first, because they both need the other one defined to be defined themselves. The only thing that's even come close to working is to have each of their CPP files include the other one's header file before including it's own header file, but that causes infinite recursion.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-24-2002 04:48

Usually this would be done with some sort of inheiritence

I'm not a C++ guy but I think the structure is something like
class Vector : public Transformation {

}

But I'm not sure.



.:[ Never resist a perfect moment ]:.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-24-2002 04:53

No, they don't inherit from each other, they just happen to use each other.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-24-2002 05:05

I figured it out. It's too complicated to explain, but basically my explanation of the problem was oversimplified, so don't worry about it. =)

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 09-24-2002 05:14

no, damnit!!

I worry!

how're you gonna explai it on the test if you can't explain it to me?

type that shit out, young man..


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 09-24-2002 05:14

I would have liked to hear the details but I'm sure you're busy getting whatever it is to work. Maybe some other time.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-24-2002 05:17

Well, essentially, you just #include the vector class from the transformation class. I didn't *think* that was working because there was another similar error related to trying to access private member variables.

To be honest, beyond that, I don't really know what the real answer is, but it's working, so I'm going to let it be =)

(note: this may have been impossible if the vector class had a transformation object as a private member variable, but it didn't; it merely took one as the argument to a function.)

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-24-2002 08:27

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

« BackwardsOnwards »

Show Forum Drop Down Menu