CString declared in header doesn't get assigned to


  • Hello all,

    I recently ran into the problem that a CString globaly defined in a header file does not get any value when it gets assigned to in the cpp file.


    In stringExample.h

    In class:


        CString cStringString;


    In stringExample.cpp

    In function: 

        cStringString = localCString;


    While localCString has a value, cStringString hasn't changed and has no value.

    Thanks for any answer/suggestion.

    Tuesday, February 20, 2007 4:51 PM

All replies

  • Hi,
    Are you sure there isn't any local variable by the same name?

    Thursday, February 22, 2007 5:37 AM
  • Hi, thanks for your reply.

    I verified it and there isn't a local variable with the same name, I also tried declaring some other CStrings in the header with different names to be sure.

    If I do the CSting = CString in the cpp file and the second one has a value, the first one (declared in the header) gets a 0x00000 <Bad Ptr> value.

    If I move the declaration from the header to the cpp file the CString = CString does work. So somehow the declaration in the header doesn't work.

    I use it in a windows mobile 5 project.

    Thursday, February 22, 2007 12:51 PM