mercredi 21 novembre 2018

Initializing static const std array

I'm trying to initialize a private static const std array in a class, but I'm getting an "incomplete type not allowed" error. Can someone tell me what I'm doing wrong?

Sample .h file:

#pragma once
#include <string>

class test
{
public:
    test();
    ~test();
private:
    static const std::array<std::string, 4> arr1;
};

Sample .cpp file:

#include "test.h"

using namespace std;

const array<string, 4> test::arr1 = { "", "", "", "" };

Error occurs at arr1 of .cpp file.

Aucun commentaire:

Enregistrer un commentaire