Reputation: 161
Simple question about instantiating an array through a constructor. I have an array of pointers to class x, I'm trying to set the array members to nullptr through the constructor.
This is my y.h
#include <array>
#include "x.h"
class y
{
public:
static const size_t number = 20;
y();
private:
std::array<x*, number> arrayList;
};
this is my y.cpp
#include "y.h"
#include "x.h"
#include <array>
using namespace std;
y::y()
: arrayList(nullptr)
{
}
Upvotes: 0
Views: 58
Reputation: 227608
Use value initialization:
y::y()
: arrayList()
{
}
or
y::y()
: arrayList{}
{
}
Upvotes: 2