Topic: Static member, private destructor


Author: pete@borland.com (Pete Becker)
Date: Wed, 22 Feb 95 08:24:56 PST
Raw View
In article <9505318.17142@mulga.cs.mu.OZ.AU>, fjh@munta.cs.mu.OZ.AU
says...
>
>ajw@ornews.intel.com (Alan Waldock) writes:
>
>>I have a class Major that has a static member of type Minor.
>>Minor's destructor is private: Major is a friend of Minor. Viz:
>>
>>class Minor {
>>friend class Major;
>>private:
>>       ~Minor() {}
>>};
>>
>>class Major {
>>public:
>>       static class Minor;
>>};
>>
>>The intent was that clients could access Major::Minor, but not actually
>>instantiate a Minor themselves. And it seemed to work. But now, my
latest
>>compiler complains that ~Minor() is private, and to pacify it, I have
had
>>to define an empty ~Major(), even though no Major is ever instantiated.
>>
>>No big deal, but my other three compilers don't complain; so can anyone
>>explain why/whether/which is correct?
>
>It looks to me like your latest compiler is buggy.
>

 More accurately, it looks like the compiler has a bug. The claim
that it is "buggy" would require more information than this post
contains.
 -- Pete





Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: Wed, 22 Feb 1995 07:53:22 GMT
Raw View
ajw@ornews.intel.com (Alan Waldock) writes:

>I have a class Major that has a static member of type Minor.
>Minor's destructor is private: Major is a friend of Minor. Viz:
>
>class Minor {
>friend class Major;
>private:
> ~Minor() {}
>};
>
>class Major {
>public:
> static class Minor;
>};
>
>The intent was that clients could access Major::Minor, but not actually
>instantiate a Minor themselves. And it seemed to work. But now, my latest
>compiler complains that ~Minor() is private, and to pacify it, I have had
>to define an empty ~Major(), even though no Major is ever instantiated.
>
>No big deal, but my other three compilers don't complain; so can anyone
>explain why/whether/which is correct?

It looks to me like your latest compiler is buggy.

--
Fergus Henderson - fjh@munta.cs.mu.oz.au
all [L] (programming_language(L), L \= "Mercury") => better("Mercury", L) ;-)




Author: ajw@ornews.intel.com (Alan Waldock)
Date: 15 Feb 1995 16:54:23 -0800
Raw View
I have a class Major that has a static member of type Minor.
Minor's destructor is private: Major is a friend of Minor. Viz:

class Minor {
friend class Major;
private:
 ~Minor() {}
};

class Major {
public:
 static class Minor;
};

The intent was that clients could access Major::Minor, but not actually
instantiate a Minor themselves. And it seemed to work. But now, my latest
compiler complains that ~Minor() is private, and to pacify it, I have had
to define an empty ~Major(), even though no Major is ever instantiated.

No big deal, but my other three compilers don't complain; so can anyone
explain why/whether/which is correct? I've tried the ARM, honest!!

-- Alan Waldock, from but not on behalf of Intel Corporation
   alan_waldock@ccm.jf.intel.com