Reputation: 3
I have a class called "File" with private field "bool[] bits". How should I create a constructor for this "File" class which only includes "bool[] bits"? Size of array is unknown. Thanks
Upvotes: 0
Views: 183
Reputation: 56479
Size of built-in arrays in C++ is part of its type. So, you can not create an array without specifying its size. BTW, Your code bool[] bits
is not a valid syntax in C++.
class File
{
std::vector<bool> bits;
public:
File(int size) : bits(size) {}
};
Upvotes: 1