stuck on array in header file
Mar 23, 2018 at 8:07pm UTC
Hey everyone, im declaring an array in my header file. When i try to define
it in my .cpp class file i cant not sure why.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
//header file
#pragma once
#include <string>
class FJumbleGame
{
public :
FJumbleGame();
private :
std::string WordList[5][2];
void SetWordList();
};
//class file
#include "FJumbleGame.h"
//Constructor
FJumbleGame::FJumbleGame()
{
}
void FJumbleGame::SetWordList()
{
WordList[5][2] = // this is where my error is says noperator matches these operands
{
{"wall" , "smash it" }
};
}
Mar 23, 2018 at 8:13pm UTC
WordList
is a 2D array of string objects.
WordList[5][2]
is the single string at location 5,2 in that array. That location doesn't event exist, so that's gone wrong, but that aside,
WordList[5][2]
is a single string.
Let's take a look at what you're trying to assign to that single string:
1 2 3
{
{"wall" , "smash it" }
};
Well that's not a single string, is it?
Mar 23, 2018 at 8:19pm UTC
Ok thank you i get that but how would i do assign all the values in the array
Mar 23, 2018 at 8:25pm UTC
Topic archived. No new replies allowed.