mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 20:47:11 +00:00
23 lines
398 B
C++
23 lines
398 B
C++
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
|
|
#include <string>
|
|
|
|
struct MyBuffer {
|
|
std::string* s_;
|
|
|
|
MyBuffer(int size) {
|
|
this->s_ = new std::string(size, char('\0'));
|
|
}
|
|
~MyBuffer() {
|
|
delete this->s_;
|
|
}
|
|
|
|
int Size() const {
|
|
return this->s_->size();
|
|
}
|
|
char* Data() {
|
|
return (char*)this->s_->data();
|
|
}
|
|
};
|