【发布时间】:2014-11-28 01:12:12
【问题描述】:
老实说,在构造函数的调用过程中,我一直纠结于如何分配数组的大小。另外,我希望数组是“常量”。这在构造函数期间可能吗?还是我必须做一些更棘手的事情?以下是部分代码:
class CustomBitmap
{
public:
CustomBitmap(int width,int height);
~CustomBitmap(void);
private:
const int m_width;
const int m_height;
char const m_components[];
};
/////////////////////////////////////// ///////////////////////////////////////// ///////////////////////////////////////// /////////////////
#include "CustomBitmap.h"
CustomBitmap::CustomBitmap(int width,int height) : m_width(width), m_height(height)
// How do I implement the array? none of the syntax works, I tried m_components([width * height *4]) and all sorts of things along that line.
{}
CustomBitmap::~CustomBitmap(void) {}
【问题讨论】:
标签: c++ arrays constructor