CString m_pchData
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: CString m_pchData

  1. #1
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    62

    Question CString m_pchData

    Ive a problem with code from VC6

    Code:
    double Double()  const                          {return atof(m_pchData);}
    Now Ive Visual 2005 and I have no idea about the new syntax . Who can halp me.

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: CString m_pchData

    What you got there seems OK. What error messages do you get?

    - petter

  3. #3
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    62

    Re: CString m_pchData

    The error message:

    error C2065: 'm_pchData': nichtdeklarierter Bezeichner

  4. #4
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: CString m_pchData

    Did you remember to declare the variable 'm_pchData'?`
    It would help if you posted some code? Maybe the whole class?

    - petter

  5. #5
    Join Date
    Apr 1999
    Posts
    3,585

    Re: CString m_pchData

    Visual Studio 6 declared m_pchData as a protected member of the CString class. Visual Studio .Net uses a template CString class CStringT that does not contain m_pchData. It appears that you are tring to access the character contents that are wrapped by CString. Why not use a function like GetBuffer()?
    Gort...Klaatu, Barada Nikto!

  6. #6
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915

    Re: CString m_pchData

    You must have derived your class from CString. That I think is completely unnecessary.
    You can use CString object as if you were using pointer to a character string or use GetBuffer/GetBufferSetLength to manipulate CString buffer.

    Since VS 7 (2002) there is no CString as it were in VS 6.0.

    I do not have access to VS other than 6.0 (I am at my customer computer) but you can check how CString is defined in 2005. It is just a typdef that uses template ATL class (ATL::CStringT if I remember correctly).
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  7. #7
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,059

    Re: CString m_pchData

    Beside Mike and John already said.

    Modify your code and use directly CString rather than the derivated class which gives you more troubles than benefits.
    For example, that poor CStringDerived::Double function can be easily replaced in your code with atof(someCStringObject);
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center