can't find an answer to this anywhere. haven't used c++ for long. in this file, 512, 256, 4736, and 448 all red-underlined as error 'expecting type specifier' 

```
// AttackSqrs.h
#include <valarray> 
#include <vector>
#include <unordered_map> 
#include <string> 
#include <iostream>

class AttackSqrs
{
public:
    AttackSqrs();
    ~AttackSqrs();

private:
    void init();
    std::valarray<int> board(512);
    std::valarray<int> vrChessPieces(256);
    std::valarray<int> vrAttackSqrs(4736);
    std::valarray<int> vrNumAttackSqrsEachSqr(448);
};

```

but when i create this header file:

```
// diag.h
#include <valarray> 
#include <vector>
#include <unordered_map> 
#include <string> 
#include <iostream>

    void init();
    std::valarray<int> board(512);
    std::valarray<int> vrChessPieces(256);
    std::valarray<int> vrAttackSqrs(4736);
    std::valarray<int> vrNumAttackSqrsEachSqr(448);

```

the errors go away. thanks in advance for any help.
['https://Stackoverflow.com/questions/25150148', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2808996/']
On the header file, you only declare the variable and their types. Any kind of object construction is implemented in the cpp file.

**AttackSqrs.h**

```
class AttackSqrs
{
public:
    AttackSqrs();
    ~AttackSqrs();

private:
    void init();
    std::valarray<int> board;
    std::valarray<int> vrChessPieces;
    std::valarray<int> vrAttackSqrs;
    std::valarray<int> vrNumAttackSqrsEachSqr;
};

```

**AttackSqrs.cpp**

```
AttackSqrs::AttackSqrs() : 
        board(512), 
        vrChessPieces(256), 
        vrAttackSqrs(4736), 
        vrNumAttackSqrsEachSqr(448){

}

```
Your question is about vectors but you use valarray, which I haven't used before. I will answer for vectors.

You need to set the size of the vectors in the constructor.

header file

```
class AttackSqrs
{
public:
    AttackSqrs();
    ~AttackSqrs();

private:
     std::vector<int> board(512);
};

```

cpp file

```
AttackSqrs::AttackSqrs()
: board(512)
{
}

```

Alternatively, as the sizes are constant, you can use arrays.

```
class AttackSqrs
{
public:
    AttackSqrs();
    ~AttackSqrs();

private:
    std::array<int, 512> board; // c++11
    int board[512]; // pre-c++11
};

```