Fast-forward to today and I find out something completely unintuitive that I honestly believed didn't work: http://ideone.com/rI2ukX
For a long time now I have been structuring my code in a way to avoid this, but it turns out it was never a problem after all. I'm going to have to go through and simplify my code now that I know this is possible (because my workarounds are needlessly overcomplicated).
you didnt know you could do that? isnt that the basis for a link list class/struct? declaring a pointer or reference to said class or struct before its finished, as long as you dont try to manipulate it?
From that article, point 4 The "right way" to include
> forward declare B if: A contains a B pointer or reference
> forward declare B if: one or more functions has a B object/pointer/reference as a parementer, or as a return type
The way it's written there it's just as useful as a void pointer.
? How do you figure?
void pointers are 'bad' because they're not typesafe. A pointer to an incomplete type is still typesafe, you just have to complete the type before you can dereference it.
I was talking about it's utility, not best practices. In both cases you can't do much with either one without more data, in the case of a void pointer it needs to be cast and in this case you need someway to tell the program what 'A' actually is.
thanks for the reference to an article I never knew I needed to read, bookmarked that, I avoided header files and therefore their problems for too long, and im not happy about coding in other languages, I dont feel like im doing anything just putting bits together.
From that article, point 4 The "right way" to include
> forward declare B if: A contains a B pointer or reference
> forward declare B if: one or more functions has a B object/pointer/reference as a parementer, or as a return type
There was no assumptions to made
You're right, I misread the article when I first read through it - maybe I took 'reference' not to mean an actual C++ reference.
@Computergeek01: I actually work with an SDK for DLLs where there is an incomplete type, and I use the value of pointers to it to differentiate between different open files in the program editor. It's not well documented and I had to take a guess and ask the developers about it, and my guess was right. If it had been only a void pointer I would have ignored it and would have been unable to achieve my goal.
I guess I said it in a really redundant way, but what I meant is that the SDK lets the DLL interface with the software properly. And no it's not the WinAPI ;p