Hey I was wondering how the string class is able to output its self the way it does.
For example:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string testString;
testString = "Hello";
cout << testString << endl;
system("PAUSE");
return 0;
}
If I were to try to make a mimic class such as
#include <iostream>
#include <string>
using namespace std;
class myClass
{
string content;
public:
void operator=(string newContent)
{
content = newContent;
}
string getContent()
{
return content;
}
};
int main()
{
myClass testString;
testString = "Hello";
cout << testString.getContent() << endl;
system("PAUSE");
return 0;
}
I have to call my getContent() function to return the content of the class.
How does the string class output its contents without needing to call a function?
Thank you to those who take the time to read this.