问个比较2的问题,vector作为class成员
class xx{
private:
std::vector< unsigned char > _pixels(_WIDTH*_WIDTH*4);
}
为嘛不可以这样用设定_pixels的大小?
谢谢
2012-10-23 10:29
2012-10-23 11:56
2012-10-23 12:18
2012-10-23 14:16
程序代码:
#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;
}
2012-10-23 14:44
程序代码:class xx
{
private:
//std::vector<unsigned char> pixels_( 4 );
std::vector<unsigned char> a_{ 0, 0, 0, 0 };
std::vector<unsigned char> b_ = std::vector<unsigned char>(4);
};
2012-10-23 14:49
程序代码:#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;
}
2012-10-23 15:31
2012-10-23 17:27