标签:cout using tls name turn std stream ret count
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
class MySTLString
{
public:
MySTLString();
MySTLString(int count, char ch);
MySTLString(const char* s);
const char& front() const;
const char& back() const;
int size() const;
private:
char* data_;
};
MySTLString :: MySTLString() : data_(new char[1])
{
*data_ = ‘\0‘;
}
MySTLString :: MySTLString(const char* s) : data_(new char[strlen(s) + 1])
{
strcpy(data_, s);
}
const char& MySTLString::front() const
{
return data_[0];
}
int MySTLString::size() const
{
return strlen(data_);
}
int main(void)
{
MySTLString str("Hello");
cout << str.front() << endl;
cout << str.size()<<endl;
return 0;
}
标签:cout using tls name turn std stream ret count
原文地址:https://www.cnblogs.com/CodeWorkerLiMing/p/11071922.html