Article View: comp.std.c++
Article #3546Re: Namespaces within class definition???
From: Steve Clamage
Date: Wed, 28 Feb 1996 21:14
Date: Wed, 28 Feb 1996 21:14
33 lines
2034 bytes
2034 bytes
In article ejv@nnrp1.news.primenet.com, kj7bg@primenet.com (Bob White) writes:
>Assuming that the "string" class is properly defined in namespace "std", is it
>legal to do the following:
>class xyz : public std::string {
>}
>I am trying to do this with Visual C++ v4.0 and it is giving me an INTERNAL
>COMPILER ERROR. I thought that this was legal syntax, but am not certain.
>Thanks in advance for your help.
Yes, it's valid. Sounds like growing pains regarding a new language feature.
Try this as a workaround:
using std::string;
class xyz : public string { ... };
The difference is that std::string is now placed in the current scope
as "string", which might collide with other names in the program.
Ideally, you will abandon "string" as a user identifier because it is
the name of a standard class. Using "string" for other purposes
will be confusing and make future maintenance more difficult.
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID:
<4h2ajf$l69@engnews1.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austernReferences:
<4h27pi$ejv@nnrp1.news.primenet.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern From: clamage@Eng.Sun.COM (Steve Clamage) Newsgroups: comp.std.c++ Subject: Re: Namespaces within class definition??? Date: 28 Feb 1996 13:14:30 PST Organization: Sun Microsystems Inc. Approved: austern@isolde.mti.sgi.com Message-ID: <4h2ajf$l69@engnews1.Eng.Sun.COM> References: <4h27pi$ejv@nnrp1.news.primenet.com> Reply-To: clamage@Eng.Sun.COM NNTP-Posting-Host: isolde.mti.sgi.com X-Original-Date: 28 Feb 1996 19:31:59 GMT X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBMTTFw0y4NqrwXLNJAQH9HAH9GallI88vMb6cluzZxMM5qVbsV86WkixI mmvUCKT9oaIgwsXXiHdnVX/pJ+pXj3fbbovUvkjkuPQ5aiJ4CpTMrw== =QfRz Originator: austern@isolde.mti.sgi.com