2
I’m trying to create a static member in a class so you don’t have to instantiate the class to get the value of the class.
In the examples I found on the internet makes references to members int
.
In my case I want the static member to be a string
.
If I do this:
class algumacoisa
{
public:
algumacoisa();
~algumacoisa();
string texto;
static string recebetexto;
};
texto = "alguma frase aqui...";
string algumacoisa::recebetexto = texto;
The following error message appears:
error: Qualified-id in declaration before ?=' token
It is only to illustrate that if you assign a normal string variable to a static string variable the error described occurs. The code is not complete, but you can get an idea of what it refers to.
Put the code you are doing, even because the explanation is confused.
– Maniero
Format the code better. I couldn’t even understand to format your question.
– Vinícius Gobbo A. de Oliveira
What code is that?
– user28595