What actually happens when we use strings
Code:
String TTextFile::Load() const
{
String Text;
ifstream File(itsPath.c_str());
if (File.is_open())
{
while (File.good())
{
Text += File.get());
}
File.close();
}
return Text;
}
Code:
char * TTextFile::Load() const
{
char *Text = "";
ifstream File(itsPath);
if (File.is_open())
{
while (File.good())
{
Length = strlen(Text);
char *Temp = new char[Length + 1]
strcpy(Temp, Text);
delete Text;
Text = new char[Length + 2];
strcpy(Text, Temp);
Text[Length] = File.get();
Text[Length + 1] = '\0';
}
File.close();
}
return Buffer;
}
I just wanted to show you all what actually happens when we use strings (though the use of strings furthermore will increase the function calls), simply because alot of people think the one above is faster then the one below and that is just wrong.