timmay3141
Programmer
I was looking at the CString class, and I noticed the following member function
operator LPCTSTR() const;
I assumed this operator automatically casts a CString to a LPCTSTR if you send it to a function that needs a LPCTSTR. I'm writing a class that could use something like this, but my book didn't talk about how to make this kind of an operator. I created a similar declaration, and an implimentantion that would look like this:
CString:
perator LPCTSTR() const
{
return m_lpszBuffer;
}
This seemed to work correctly at first. However, it did not work when I was creating other operators. I had to create a specific operator for both the char* type and the actual class type. I also noticed that, under the globals folder in the classview, a function titled "$S1()" shows up. I actually created two of these operators, so an "$S2()" shows up as well. Am I doing something wrong?
operator LPCTSTR() const;
I assumed this operator automatically casts a CString to a LPCTSTR if you send it to a function that needs a LPCTSTR. I'm writing a class that could use something like this, but my book didn't talk about how to make this kind of an operator. I created a similar declaration, and an implimentantion that would look like this:
CString:
{
return m_lpszBuffer;
}
This seemed to work correctly at first. However, it did not work when I was creating other operators. I had to create a specific operator for both the char* type and the actual class type. I also noticed that, under the globals folder in the classview, a function titled "$S1()" shows up. I actually created two of these operators, so an "$S2()" shows up as well. Am I doing something wrong?