Topic: an extension idea that someone else mig


Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 6 Sep 1994 16:10:07 GMT
Raw View
In article t1s@news.u.washington.edu, ghogenso@u.washington.edu (Gordon Hogenson) writes:
>rjl@f111.iassf.easams.com.au (Rohan LENARD) writes:
>
>>Additionally, the committee have gone out of their way to allow things to
>>be split over multiple places. eg a namespace can be split into multiple
>>parts just be defining it in different spots.
>>eg. (from Bjarne's great book D&E of C++)
>
>> namespace Mine {
>>   void f();
>>        };
>
>>        #include <stdio.h>
>
>>        namespace Mine {
>>          int g();
>>        };
>
>Are you saying that it is possible to have:
>
>foo.h:
>
>   class Foo {
>       Foo();
>       ~Foo();
>       foofunction();
>    };
>
>foo.cc:
>
>   namespace Foo {
>       Foo() { // ctor for Foo }
>       ~Foo() { //dtor code }
>    }
>
>   //.... stuff
>
>   namespace Foo {
>       foofunction() { code for this function }
>     };
>
>Is this allowed?  Every class defines a namespace, does it not?

No. A class creates a scope, which is in effect a namespace, but a namespace
is not a class.

Splitting a class definition is not allowed.

A namespace is purely a scope. A class is a type as well as a scope.

---
Steve Clamage, stephen.clamage@eng.sun.com