Thread: class structure, a little help please!

  1. #1
    Registered User
    Join Date
    Mar 2002

    class structure, a little help please!

    class Name {

    Name( char *, char * );
    bool operator==( const Name &n ) const;
    const Name operator+=( const Name &n );
    char first[ 26 ];
    char last[ 26 ];
    friend ostream &operator<<( ostream &, const Name &n );
    friend istream &operator>>( istream &, Name &n );


    Name::Name(char *thefirst, char *thelast )


    ostream &operator<<( ostream &output, const Name &n )
    output << n.first << n.last;
    return output;
    istream &operator>>( istream &input, Name &n )
    input >> setw( 26 ) >> n.first;
    input >> setw( 26 ) >> n.last;
    return input;

    bool Nameerator==( const Name &n ) const
    if (n.first != n.last )
    return false;

    if ( n.first == n.last )
    return true;

    Nameerator +=( char )
    Name&last += Name&first;
    return &last;

    char main()
    Name name;
    cout << "Enter full name in the form of abcdefghijk abcdefghijk:\n";
    cin >> name;

    cout << " The name entered was: " << name << endl;

    return 0;
    Okay I have tried what acouple of your suggestions and it still won't work. I guess I just don't understand. My teacher says that I have to use the == and += operators, so that's why that part is there. I think I just don't get the argument part and then using the main to use the class.

  2. #2
    Where in the heck is your CONSTRUCTOR, I see the overloaded one but I don't see the Name() one. I don't see any code in your constructors either.

    You ought to declare your Classes in .h (header) files.
    In your perator..() fxn's why is there Name&last=..., this is not the way, grrrrl.
    My Avatar says: "Stay in School"

    Rocco is the Boy!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Structure vs. Class
    By bobbelPoP in forum C++ Programming
    Replies: 4
    Last Post: 07-09-2008, 09:44 AM
  3. Need help to build network class
    By weeb0 in forum C++ Programming
    Replies: 0
    Last Post: 02-01-2006, 11:33 AM
  4. Mmk, I give up, lets try your way. (Resource Management)
    By Shamino in forum Game Programming
    Replies: 31
    Last Post: 01-18-2006, 09:54 AM
  5. Converting a C structure into a C++ class
    By deadpoet in forum C++ Programming
    Replies: 7
    Last Post: 01-07-2004, 02:06 PM