问个比较2的问题,vector作为class成员
class xx{
private:
std::vector< unsigned char > _pixels(_WIDTH*_WIDTH*4);
}
为嘛不可以这样用设定_pixels的大小?
谢谢
程序代码:
#include <vector>
class xx
{
public:
xx() : val_(4), pixels_(4)
{
}
private:
int val_;
std::vector<unsigned char> pixels_;
public:
static const int scint = 123;
static const float scflt;
};
const float xx::scflt = 123.456f;
int main()
{
int a = xx::scint;
float b = xx::scflt;
return 0;
}
程序代码:#include <vector>
#include <iostream>
using namespace std;
class test
{
public:
test(){cout << "test::test()" << endl; }
test(const test&t){cout << "test::test(const test&t)" << endl; }
};
int main()
{
vector<test> ivec(50);
cout << ivec.size() << endl;
return 0;
}