473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Protected classes within classes

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?

Thank you,
Kevin Grigorenko
Jul 22 '05 #1
6 1434
"Kevin Grigorenko" <kz****@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
Jul 22 '05 #2
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:ExLzb.427632$Fm2.428775@attbi_s04...
"Kevin Grigorenko" <kz****@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? Are you
implying that this is allowed and that VC++ 6 just can't handle it? And if
so, what options do I have, if any, without taking the class out of the
BasicRegex class and making it public?
Jul 22 '05 #3
"Kevin Grigorenko" <kz****@psu.edu> wrote...
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:ExLzb.427632$Fm2.428775@attbi_s04...
"Kevin Grigorenko" <kz****@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
Jul 22 '05 #4
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:fXMzb.303527$275.1043028@attbi_s53...
"Kevin Grigorenko" <kz****@psu.edu> wrote...
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:ExLzb.427632$Fm2.428775@attbi_s04...
"Kevin Grigorenko" <kz****@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
Jul 22 '05 #5
> Thanks! I appreciate it. I didn't think MSVC++ 6 was that bad.

It is that bad.
.NET seems
to be quite an improvement then.
It is.
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.
Sometimes there is a good reason stick with an older compiler. Even though
MSVC 6 is old and very far from being compliant with the C++ standard, it is
still widely used. On the other hand there is something to say for
stimulating people to use a compliant compiler, otherwise we will be stuck
with MSVC6 forever. So the desision is up to you :-)
Do you think I'll have these kinds
of problems with GCC from your experience (if you have any experience with
GCC)?


If you use a recent GCC version (3.X) I would expect not; it is a very good
compiler.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
Jul 22 '05 #6
>
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


Just in case I ask, does your friend have Service Pack 5 installed,
for VC6? I used to have VC6 and it was useless until I got SP5
installed, then it was somewhat passable.
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Carlos J. Quintero | last post by:
Hi, As you know the current keywords "protected internal" (C#) or "Protected Friend" (VB.Net) means "Protected Or internal" (C#) or "Protected Or Friend" (VB.Net), that is, the member is...
6
by: Sgt. Sausage | last post by:
I know it's not possible, but I need a protected internal interface: protected internal interface ISomeInterface{ // yadda yadda yadda } Basically, I need an interface that is completely...
2
by: Kolozs, Áron | last post by:
Hi everybody, The C# compiler reports a Compiler Error CS0052 in the following situation: I declared a type marked as "internal": namespace MyNamespace { internal class MyInteralClass
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
4
by: newbie120 | last post by:
Hi all maybe its just been a long day, but i have a question about call access modifiers in C#. Consider the following code. namespace Application { private class Class1 { int i;
86
by: jopperdepopper | last post by:
Hi, finally giving php 5 a go, and going over the new approach to classes. Can someone clarify the public, private and protected to me? I quote the php manual: "The visibility of a property or...
16
by: Fir5tSight | last post by:
Hi All, I have a small C#.NET program that is as follows: using System; class A { protected int x = 123; }
5
by: Jameson | last post by:
Hi, I have a property defined something like: Public Property Index As Integer Get Return m_Index End Get
8
by: Mayur H Chauhan | last post by:
All, For my knowledge, if I declare Class as follow, then it thows compilation error. Protected Class Book End Class Even same for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.