I'm new to C++ and i was experimenting a bit with some of its features (mainly templates, pointers, OOP) trying to build a string class, when I got stuck in this problem. The incriminated code looks like this:
string.h
...
private:
char* value;
...
public:
string();
...
string.cpp
string::string() : value( '\0' ) {
std::cout << "Initialized string value: " << this->value << "blablabla" << std::endl;
}
What I thought would happen is that the "value" class' memeber got initialized as an empty string as soon as the constructor got called, but apparently I was wrong, since when I call it, I see this on the console:
"Initialized string value: "
Now, why does the output get kind of truncated once it prints the "value" class member? What am I doing wrong?