Can anybody please tell me the issue with the below is due to the const keyword or any other reason? the following does not work:-
bool fun(const CString strName)
{
CUpdate param;//User defined calss
param.pObject = reinterpret_cast<CObject*>(strName);
--------
-----
}
but this works:-
bool fun(const CString strName)
{
CString strJobName = strName;
CUpdate param;//User defined calss
param.pObject = reinterpret_cast<CObject*>(strJobName);
--------
-----
}
Please do not mind but i have something to say for you,
I have observed this kind of wrong concept written by you for the second time now.
1st is the above mentioned CString
and
second is your reply for stack concept at, "The design and evolution of C++", by satm2008
My point is we should be careful while posting any answers. At least conceptually.
So out of some 700 posts I've made a typo and a mistake.
I wish you high-and-mighty people would get off your pedestals and stop wasting bandwidth attacking people instead of responding to problems. I don't mind being corrected, but I do mind being abused by weenie-wannabes.
The problem is that you are misusing reinterpret_cast<> when you should be using const_cast<>. But, considering CString doesn't derive fro CObject, then what makes you think your code will work to begin with?
At least satm2008 has the good sense to give someone the benefit of error.
So congradulations, you've officially made my ignore list.
@KDevloper
everybody is careful posting answers. The windows class hierarchy is extremely complicated like everything else microsoft touch and it is very easy to make mistakes about what inherits from what etc. If it had been me answering the post, i would have assumed from your code that you had figured out that it did derive from CObject, it is a reasonable assuption unless you actually know, I suspect Duoas made the same assumption. Trying to rub an error in someones face, that was caused by assuming you knew what you were trying to do is not the way to make friends in here,
Following on from Duoas and bnbertha. Microsoft do an absolutely crap job of implementing anything even remotely close to a standard (that they didn't develop).
.NET C++ has alot of wonderful changes that most C++ developers (who use non-microsoft kit) will not know about. Therefore, in order for us to provide some help we have to make assumptions about Microsoft's decisions. It's not unreasonable to assume everything inherits from CObject (similar to Java, that Microsoft "borrowed" for C#/.NET).
I have not used any abusing language here.If you do not mind being corrected, then why do you turn things in a bad way. You can ignore me or i can ignore you also , but we are here as a team to correct each other.i agree with your point also of misusing reinterpret_cast<> when i should be using const_cast<>, So i thank you for the suggestion.
While using MFC, we Should not assume that all classes are derived from CObject.
Any way dont take it in any other way..dear.. you and i and all of us here are high-and-mighty people(Actually wat does it mean?).