access to private members of internal class

From: Shea Martin (smartin_at_arcis.com)
Date: 04/08/04


Date: Thu, 08 Apr 2004 15:14:39 -0600

Class A
{
public:
    class B;
    int funct(const B &b);
};

Class A::B
{
private:
    int _member;
};

int A::funct(const A::B &b)
{
    return 10*b._member; //won't compile
}

////////////////////////////
The above code will not compile, as I get a error to the effect of
member _member not accessable from A::funct(const A::B&)

Is there anyway around this, short of declaring _member to be public?

Thanks,

~S



Relevant Pages

  • Re: intrestring puzzle
    ... yes u r rite.but its possible to access a private member directly by ... >> int main ... >> The following source file does not compile. ...
    (comp.lang.cpp)
  • Re: Reading the name of a variable
    ... > This should only work with the variable is a member of a type, ... depend on irrelevant details of the source, ... if you take a program and just change all the (private) variable names, ... you will compile to identical IL... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Avoiding rtti
    ... p.data is not accessible to Visitor here because it is a private ... member of Parameter. ... friend of Parameter, and it should compile. ...
    (comp.lang.cpp)
  • Re: How do I write to a textbox in a form from within a class
    ... you can control the level of access for each class member. ... Protected Friend ... Private PrivateVar As Integer ... to your TextBox issue ... ...
    (microsoft.public.dotnet.languages.vb)
  • Re: "this" and "base"
    ... compiler and the programming language. ... a private inherited field in a base class from a derived class is that the ... > because the member "is a private". ...
    (microsoft.public.dotnet.languages.csharp)