本文介绍了通过引用返回CTypedPtrArray对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我像
创建了CTypedPtrArrayCTypedPtrArray< CObArray,COverLayItems *> myArray;

在MFC的文档类中,其中"COverLayItems"是由我创建的可序列化的类.现在,我需要从其他类访问此array(myArray),因为它被声明为私有数组,因此我必须编写一些成员函数来获取和设置此数组.
请帮帮我..
我如何通过引用返回此myArray ...

在此先感谢

i havae created CTypedPtrArray like
CTypedPtrArray<CObArray,COverLayItems*> myArray;

in the document class in MFC where "COverLayItems" is serializable class created by me. Now i need to access this array(myArray) from other classes because it is declared as private i have to write some member functions for getting and setting this array.
please help me for that..
how i can return this myArray by reference...

Thanks in advance

推荐答案

// yours.h

typedef CTypedPtrArray<CObArray,COverLayItems*> CItems;

class C
{
  CItems m_cItems;
..
public:
..
  CItems& GetItems() const { return m_cItems; }
  // const CItems& GetItems() const { return m_cItems; }
..
};


这篇关于通过引用返回CTypedPtrArray对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 04:09