Why we need to put const in front of array of string , dealing with enumeration. I want to convert from number enum to string
Why we need to put const in front of array of string , dealing with enumeration. I want to convert from number enum to string . I mean this const string str[8] #pragma once #include <iostream> using namespace std; #include<string> enum KOLONA { A, B, C, D, E, F, G, H }; const string str[8] = { "A","B","C" ,"D", "E", "F", "G", "H" }; class Polje { KOLONA kol; int red ; public: Polje(); Polje(KOLONA koll,int redd) :kol(koll),red(redd) { } friend bool operator==(const Polje& p1, const Polje& p2) { return (p1.kol == p2.kol) & (p1.red == p2.red); } friend bool operator+ (const Polje& p1, const Polje &p2) { return (p1.kol == p2.kol) || (p1.red == p2.red); } friend bool operator/(const Polje& p1, const Polje& p2) { return (p1.kol-p2.kol)==(p1.red-p2.red) ; } const string getKol() { return str[kol]; } int getRed() { return red; } ~Polje(); };