There is an error that does not stop to compile and I do not understand, I explain, I pretend to make the power of a language, eg given a language L {0,1}, do L ^ 2, that would give us { 00,01,10,11}.
That's what I intend to do in my code, however, the next one comes out and
passing 'const std::basic_string<char>' as 'this' argument of 'std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' discards qualifiers [-fpermissive]
referring to the line of my code:
(*it1)=iter;
This is the code:
void operaciones::potencia(int exponente){
set<string>::iterator it1;
set<string> result;
char it2;
char it3;
int i;
int j;
int contador=0;
while(contador<exponente){
for(it1=lenguaje.begin(); it1!=lenguaje.end(); it1++){
for(i=(*it1)[i]; i<(*it1).size();i++){
for(j=(*it1)[j]; j<(*it1).size();j++){
char k=(*it1)[j];
string iter=(*it1);
iter.push_back(k);
(*it1)=iter;
}
result.insert((*it1));
}
}
contador++;
}
write(result,cout);
}
Class builders
operaciones::operaciones(const string cadena){
string h; //si, solo se usa en esta funcion, se declara en esta funcion
int i=0; //en set son desde 0
//en un lenguaje no puede haber dos cadenas repetidas, es redundante tener mas de una
int longitud=cadena.length();
// un while de entrada no sirve porque si encuentra una coma no vuelve a entrar
for (int i=0; i<longitud;i++){ //es caracter por caracter
while(cadena[i]!='{' && cadena[i]!= ',' && cadena[i]!= '}' && i<longitud){ //las comparaciones con comilla simple, caracteres con comilla simple, string con una doble!!!
h.push_back(cadena[i]);
i++;
}
if (cadena[i]==',' || cadena[i]=='}' ){
lenguaje.insert(h); //contenido de string
h.clear();
}
}
}
operaciones::operaciones(const operaciones& lenguaje3){//constructor de copia
lenguaje=lenguaje3.lenguaje;//accediendo atributo lenguaje3
}
Really, I thank you for explaining where you see the bug and how to correct it
Thanks