Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Programming

Journal Milican's Journal: Forward Declarations Tips for C++

I was recenlty on a Forward Declarations frenzy in C++, and I was having a little trouble. I recently bought a subscription to SuperNews so I could check comp.std.c++, comp.lang.c++.moderated, and other programming related newsgroups. That subscription definitely paid off because a few days later it helped point out why I was having some errors in my code. Here is an edited copy of the thread I found titled "Forward Declaration" (Subscription Required) in comp.std.c++:

---------------------------------------

>1) class a_class; //forward declaration
> class another_class
> {
> a_class object;
> };

This is not legal. All members must be complete.

> 2) class a_class
> class another_class
> {
> a_class* object
> }

This is perfectly OK.

> 3) class a_class; //forward declaration
> class another_class : public a_class
> {
> };

Again, this is not legal. Base classes must also be complete. -Richard Smith

---------------------------------------

Big thanks to Richard!

JOhn

The use of money is all the advantage there is to having money. -- B. Franklin

Working...