Retrieving CObArray from method

Hi, I need to manage a CObArray object in a class, but this object must be retrieved from another class. How can I implement the method of this class to get retrieved the object in the first class


Answer this question

Retrieving CObArray from method

  • adi1980

    Yeah, that works. Thanks

  • DouglasJB

    You can try using friend class declaration like below in unmanaged stuff.

    class ObjArrClass
    {
    friend class NeedObjArrClass; // Declare a friend class
    public:
    ObjArrClass(){ cArray.SetSize(100);}

    private:
    CObArray cArray;
    };

    class NeedObjArrClass
    {
    public:
    void PrintSize( ObjArrClass& objClass )
    {
    printf("Size is : %d...",objClass.cArray.GetSize());
    }
    };

    P.S: I guess friend classes are not allowed in Managed types and also friend class has its own advantages and disadvantages.


  • LitePipe

    raulhsj wrote:
    Hi, I need to manage a CObArray object in a class, but this object must be retrieved from another class. How can I implement the method of this class to get retrieved the object in the first class

    Perhaps, something like :-

    class A
    {
    CObArray m_arr;
    public:
    CObArray& GetObArray()
    {
    return m_arr;
    }
    };

    class B
    {
    public:
    void F()
    {
    A a;
    a.GetObArray().GetCount();
    }
    };



  • Retrieving CObArray from method