Hi,
I am relatively new at c++. I am writing a code with
operators and i'm with some problems in this part.
Anyway, it appears an warning during the compilation:
warning C4700: uninitialized local variable 'temp' used.
I can't not to understand how put it on right way,
because in execution it shows a debug error: variable not initialized.
( I see, it is not initialized, but when i try do that
many errors occurs )
( initialized the variable, like this --- str_type temp(" "); )
The following code receives 2 strings then it would concatenate them.
warning C4700: uninitialized local variable 'temp' used.
As you say, the warning is because you are not initializing temp. The reason you can't do str_type temp(" ") is because you have not defined a constructor that takes those parameters. You need to declare temp, then define it's members manually or define a constructor that takes those parameters.
In first place, I want to thank for the time you spent on this problem.
But, I think my dificult is to define a constructor that takes those parameters,
or it is with strcpy statement
I have tried this but with another code, with a constructor like you said,
and there was the same result.
here, another code with the same problem if you don't mind.
temp is initialized in the constructor to point to a string literal. Most compilers will put the string literal into code space. Thus temp points
to read-only memory.
assign() does a strcpy() which then attempts to copy the string to
code space.