I have
what did I do wrong?Code:void* classname::data(){ //this function works fine return data; } classname::operator char*(){ //this one cause the program to crash return (char*)(data()); }
I have
what did I do wrong?Code:void* classname::data(){ //this function works fine return data; } classname::operator char*(){ //this one cause the program to crash return (char*)(data()); }
what's the type of data?
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
data is void* type
How are you setting data, and how are you using classname in a char* context? One way or another the two don't work together.
In general you should avoid void * and C casts because they undermine the type system.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
this is what I have to do
create :
operator char*();
Overload the char* cast to return the value of _Label.data()
_Label.data() return a void* type.
so what I did was
Code:classname::operator char*(){ //this one cause the program to crash return (char*)(_Label.data()); }
That's great, but that doesn't set the value of data, or use the resultant char *.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
I think my syntax is correct.
The problem probably lie on what actually inside data ><.
Your program compiled, so it is possible that the syntax is correct. A correct program has correct syntax, but not all programs with correct syntax are correct. So...Originally Posted by byebyebyezzz
Originally Posted by Elysia
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I fixed the porblem. (the problem was with my team member's code)
It's working fine now.
Thanks all