Re: friend class

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"Boni" <oilia@nospam> schrieb:
I would like to have an access from one class to the private variables of other. But I also can't find a right sintax. The word "friend" seems to do something else, VB compiler still complains.
-----C++--------


class A{
private:
int K;
}
class B{
friend class A;

void test(){
A oA;
A.K=10; //acccess private member
}
}

That's not supported.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


.



Relevant Pages

  • Re: C++ in ternms of C
    ... int b, c, d; ... To consider the other aspects of OOP, we obviously have public, private and ... In short, imagine the compiler ripping all of the functions out of a class, ... I tried to analise the ASM file produ ced my the VC++ compil er. ...
    (microsoft.public.vc.language)
  • Re: question
    ... >class A(const int l) ... show us the same code that your compiler saw if you tell us about an error ... so it wouldn't accept a subsequent definition of an A object ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Why does compiler only look at public methods of superclasses of...?
    ... Compiler enumerates all methods in class A and all public methods ... in the superclasses of A to find methods named x ... if method is declared final, static or private then compiler knows ... override a protected method. ...
    (comp.lang.java.programmer)
  • Re: Some Qs related to VTable and DialogBox!
    ... int main ... Does the compiler might have created VTable for Class B or ... Does virtual functions have any effect wiht access specifiers? ... if you make A::VFuncprivate, ...
    (microsoft.public.vc.mfc)
  • Question about use and host association
    ... IMPLICIT NONE ... PRIVATE ... SUBROUTINE mytype_Write ... Is this compiler message bogus, or am I misunderstanding something about use and/or host ...
    (comp.lang.fortran)