I'm trying to create a static member in a class so I do not need to instantiate the class to get the value of the class.
In the examples I found on the internet, it references members int
.
In my case I want the static member to be a string
.
If I do the following:
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 just to illustrate that if you assign a normal string variable to a static string variable, the described error occurs. The code is not complete, but you can get an idea of what it refers to.