at school,I was given the class aName and asked to overload the input operator.the class has declared surname as type of char* and the surname is input from the keyboard and it must not be empty.please help me with the code.the class has declared the operator as its friend
khotso 0 Newbie Poster
Recommended Answers
Jump to Postpost the class then we can discuss how to implement to >> operator.
Jump to Post>>surname=aSurname;
First you have to allocate space for surname then call strcpy() to copy it
surname = new char[strlen(aSurname)+1]; strcpy(surname, aSurname);
All 6 Replies
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
khotso 0 Newbie Poster
daviddoria 334 Posting Virtuoso Featured Poster

jencas
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.