locked
Using string class RRS feed

  • Question

  • Hi all i, i start vc++ not long ago, and i cant make string class work

     

    // typedef String Telem; - Error

    typedef char (*Telem)[25];

    class Tliste {
        public:
          Telem name;
          Tliste *svt;
          Tliste() {svt = NULL;};
    };

    like this it work great, but when i change char* to string it shows error, i already have include strings in my header.

     

    1>d:\projects\win32form\wcfd\dictionaire word catcher\Arbre.h(2): error C2146: syntax error : missing ';' before identifier 'Telem'

    1>d:\projects\win32form\wcfd\dictionaire word catcher\Arbre.h(2): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>d:\projects\win32form\wcfd\dictionaire word catcher\Arbre.h(2): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>d:\projects\win32form\wcfd\dictionaire word catcher\Arbre.h(6): error C2146: syntax error : missing ';' before identifier 'name'
    1>d:\projects\win32form\wcfd\dictionaire word catcher\Arbre.h(6): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>d:\projects\win32form\wcfd\dictionaire word catcher\Arbre.h(6): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    Seems like it not see it, i dont know where to put include or if i write good.



    • Edited by Sodb Monday, January 9, 2012 5:26 PM
    Monday, January 9, 2012 5:07 PM

Answers

  • >like this it work great, but when i change char* to string it shows error, i already have include strings in my header.

    You should use std::string in your header file uses of string.

    In your source file you could fully specify std::string or use: using
    namespace std;

    Dave

    • Marked as answer by Sodb Monday, January 9, 2012 5:41 PM
    Monday, January 9, 2012 5:38 PM

All replies

  • >like this it work great, but when i change char* to string it shows error, i already have include strings in my header.

    You should use std::string in your header file uses of string.

    In your source file you could fully specify std::string or use: using
    namespace std;

    Dave

    • Marked as answer by Sodb Monday, January 9, 2012 5:41 PM
    Monday, January 9, 2012 5:38 PM
  • Thanks, work great.
    Monday, January 9, 2012 5:45 PM