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
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
adi1980
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
Perhaps, something like :-
class A
{
CObArray m_arr;
public:
CObArray& GetObArray()
{
return m_arr;
}
};
class B
{
public:
void F()
{
A a;
a.GetObArray().GetCount();
}
};