As a beginner in C++, going through a sample program, While I do understand the concept of classes, I'm not sure how the 'operator' is integrated with the classes in the code below.
So if a class is defined in the format below.
class String{
private:
// this is the data member
char *ptr;
public:
// this is one constructor
String();
// This is another constructor
String(char *s);
// Now This is the line that I dont understand. What is the
//purpose of the line below when declaring a class.
operator char*() {return ptr;}
};
What I don't understand is, how does the operator function? I believe it is linked to the String(Char *s) constructor. But I'm not able to make the link. Any help would be appreciated.