QScopedArrayPointer 类

The QScopedArrayPointer class stores a pointer to a dynamically allocated array of objects, and deletes it upon destruction. 更多...

头: #include <QScopedArrayPointer>
qmake: QT += core
Since: Qt 4.6
继承: QScopedPointer

注意: 此类的所有函数 可重入 .

公共函数

QScopedArrayPointer ()
QScopedArrayPointer (D * p )
void swap (QScopedArrayPointer<T, Cleanup> & other )
T & operator[] (int i )
const T & operator[] (int i ) const

详细描述

The QScopedArrayPointer class stores a pointer to a dynamically allocated array of objects, and deletes it upon destruction.

A QScopedArrayPointer QScopedPointer that defaults to deleting the object it is pointing to with the delete[] operator. It also features operator[] for convenience, so we can write:

void foo()
{
    QScopedArrayPointer<int> i(new int[10]);
    i[2] = 42;
    ...
    return; // our integer array is now deleted using delete[]
}
					

成员函数文档编制

QScopedArrayPointer:: QScopedArrayPointer ()

构造 QScopedArrayPointer 实例。

QScopedArrayPointer:: QScopedArrayPointer ( D * p )

构造 QScopedArrayPointer and stores the array of objects pointed to by p .

void QScopedArrayPointer:: swap ( QScopedArrayPointer < T , Cleanup > & other )

Swap this pointer with other .

T &QScopedArrayPointer:: operator[] ( int i )

Provides access to entry i of the scoped pointer's array of objects.

If the contained pointer is null , behavior is undefined.

另请参阅 isNull ().

const T &QScopedArrayPointer:: operator[] ( int i ) const

Provides access to entry i of the scoped pointer's array of objects.

If the contained pointer is null , behavior is undefined.

另请参阅 isNull ().