Article View: comp.std.c++
Article #2954Re: Can typedef be used as base class?
From: Steve Clamage
Date: Wed, 20 Dec 1995 07:26
Date: Wed, 20 Dec 1995 07:26
43 lines
1764 bytes
1764 bytes
Max Motovilov <max@int.com> writes:
>Basically the question is in the subject. I looked through the Sept. draft and haven't
>found anything against it (since typedef is a class-name if it names a class).
That is correct. You can use a typedef name that names a class anywhere
a class name is needed.
>But a
>friend of mine told me that he saw some [authoritative] objections to it in this
>newsgroup.
You have the usual rules of scope and accessibility, and you can't use
a typedef name as the name of a constructor or destructor, but I don't
know of any other restrictions offhand.
>In particular I'm interested if it does apply to member typedefs, esp. of
>template classes (is the following code legal?):
>template <class p>
>class A
>{
> ...........
>public:
> typedef A<p> Object;
> ...........
>};
>class B { ....... };
>class C : public A<B>::Object { ....... };
I believe that code is legal, if obscure. I wouldn't be surprised to
find compilers (not to mention human readers) confused by it.
--
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<4b80cd$2js@engnews1.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!howland.reston.ans.net!agate!agate!mattReferences:
<4b6obn$40r@engnews1.Eng.Sun.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!howland.reston.ans.net!agate!agate!matt From: clamage@Eng.Sun.COM (Steve Clamage) Newsgroups: comp.std.c++ Subject: Re: Can typedef be used as base class? Date: 20 Dec 1995 07:26:42 GMT Organization: Sun Microsystems Inc., Mountain View, CA Approved: matt@Austern (Matt Austern) Message-ID: <4b80cd$2js@engnews1.Eng.Sun.COM> References: <4b6obn$40r@engnews1.Eng.Sun.COM> NNTP-Posting-Host: austern.hip.berkeley.edu