Thread: HELP ME ABOUT string

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    3

    Exclamation HELP ME ABOUT string

    This code doesn't compile and i couldn't find why.
    I work in visual c++ environment.
    It gives these family of errors:

    *syntax error : missing ';' before '->'
    *'root' : missing storage-class or type specifiers
    *'root' : 'int' differs in levels of indirection from 'class data *'


    Thanks a lot for helping
    *******************************************
    #include <iostream>
    #include <string>
    using namespace std;

    class data{
    public:
    data();
    string myname;
    };
    data::data(){};
    main(){
    data *root=new data();
    (root->myname)="/";
    return 0;
    }
    ********************************************

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    It compiled for me. I think I remember some problem with some versions of MSVC and the string header. You could try getting the latest service pack or try re-arranging the order in which you include the headers.
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. compare structures
    By lazyme in forum C++ Programming
    Replies: 15
    Last Post: 05-28-2009, 02:40 AM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM