now what is wrong with this code!
Header:
#pragma once
#include <string>
using namespace std;
class Menu
{
public:
Menu(string []);
~Menu(void);
};
Implementation:
#include "Menu.h"
string _choices[];
Menu::Menu(string items[])
{
_choices = items;
}
Menu::~Menu(void)
{
}
compiler is complaining:
error C2440: '=' : cannot convert from 'std::string []' to 'std::string []'
There are no conversions to array types, although there are conversions to references or pointers to arrays
there is no conversion! so what is it on about?
please help, just need to pass a bloody array of strings and set it to Menu class _choices[] attribute.
thanks
Array’s cannot be assigned, and your arrays have no sizes anyway. You probably just want a
std::vector:std::vector<std::string>. This is a dynamic array of strings, and can be assigned just fine.