Re: Protected classes within classes
From: Kevin Grigorenko (kzg110_at_psu.edu)
Date: 12/04/03
- Next message: E. Robert Tisdale: "Re: deleting an object twice?"
- Previous message: Victor Bazarov: "Re: Protected classes within classes"
- In reply to: Victor Bazarov: "Re: Protected classes within classes"
- Next in thread: Peter van Merkerk: "Re: Protected classes within classes"
- Reply: Peter van Merkerk: "Re: Protected classes within classes"
- Reply: Dan W.: "Re: Protected classes within classes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 4 Dec 2003 15:48:56 -0500
"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:fXMzb.303527$275.1043028@attbi_s53...
> "Kevin Grigorenko" <kzg110@psu.edu> wrote...
> > "Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
> > news:ExLzb.427632$Fm2.428775@attbi_s04...
> > > "Kevin Grigorenko" <kzg110@psu.edu> wrote...
> > > > Hello,
> > > >
> > > > I've been working on a little side project of mine in Visual
> Studio.NET
> > > for
> > > > about the last month. Recently, I wanted a friend of mine to help
me
> > out
> > > > with a problem and so I sent him my files and he tried to compile my
> > > project
> > > > in Visual C++ 6. A slew of random warnings and errors appeared
which
> I
> > > > managed to solve very easily, but then I got an error that I
suddenly
> > > could
> > > > not get access to a protected class within a class from that
classes'
> > > member
> > > > functions. So, here is the basic layout:
> > > >
> > > > class BasicRegex
> > > > {
> > > > protected:
> > > > class RegexNode
> > > > {
> > > > public:
> > > > std::vector< RegexNode *>::reference addNode();
> > > > ...
> > > > };
> > > > public:
> > > > ...
> > > > };
> > > >
> > > > Then I had a member function in RegexNode called addNode which
> > essentially
> > > > looked like this in my implementation file:
> > > >
> > > > std::vector<BasicRegex::RegexNode *>::reference
> > > > BasicRegex::RegexNode::addNode()
> > > > {
> > > > children_.push_back(new BasicRegex::RegexNode);
> > > > return children_.back();
> > > > }
> > > >
> > > > And MSVC++ 6 couldn't handle the line children_.push_back(new
> > > > BasicRegex::RegexNode); It was saying that I didn't have access to
> the
> > > > protected class RegexNode for some reason.
> > > >
> > > > What is going on here? Have I created something that is
non-standard,
> > but
> > > > that .NET somehow accepts? Or is .NET correct, and MSVC++ 6
incorrect
> > in
> > > > handling the nested class? What does the standard say about this
> > > situation?
> > >
> > > My guess is that VC++ v 6 is so bad that you would do world a favour
> > > if you switch your friend to a different compiler.
> > >
> > > Victor
> > >
> > >
> >
> > Hahaha, I agree, but in the long run I wouldn't mind this working on
VC++
> 6
> > and I really would rather not make the RegexNode class public. So the
> > question of what the standard says about this is still outstanding?
>
> Members of a class have access to that class implicitly.
>
> > Are you
> > implying that this is allowed and that VC++ 6 just can't handle it?
>
> Yes.
>
> > And if
> > so, what options do I have, if any, without taking the class out of the
> > BasicRegex class and making it public?
>
> You better ask in microsoft.public.vc.language. I am afraid, however,
> that even there you'll be encouraged to update your compiler...
>
> Victor
>
>
Thanks! I appreciate it. I didn't think MSVC++ 6 was that bad. .NET seems
to be quite an improvement then. Oh well, I guess I will just suggest
anyone trying to compile my program to either update their compiler :) or
move the class outside the outer class. Do you think I'll have these kinds
of problems with GCC from your experience (if you have any experience with
GCC)?
Thanks for your time,
Kevin Grigorenko
- Next message: E. Robert Tisdale: "Re: deleting an object twice?"
- Previous message: Victor Bazarov: "Re: Protected classes within classes"
- In reply to: Victor Bazarov: "Re: Protected classes within classes"
- Next in thread: Peter van Merkerk: "Re: Protected classes within classes"
- Reply: Peter van Merkerk: "Re: Protected classes within classes"
- Reply: Dan W.: "Re: Protected classes within classes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|