#include #include #include #include #include #include #include #include using namespace std; class A { public: A() :c(3), b©, a(b) {} public: int a; int b; int c; }; class MyString { public: explicit MyString(char *ch, size_t length); MyString(const MyString &other); MyString & operator=(const MyString &other); void printch() { cout << this->str_ << endl; } private: size_t length_; char *str_; }; MyString::MyString(char *ch, size_t length) { this->length_ = length; this->str_ = new char[this->length_]; strcpy(this->str_, ch); } MyString::MyString(const MyString &other) { this->length_ = other.length_; this->str_ = new char[this->length_]; strcpy(this->str_, other.str_); } MyString& MyString::operator=(const MyString &other) { if (this == &other) { return *this; } delete[] this->str_; this->length_ = other.length_; this->str_ = new char[this->length_]; strcpy(this->str_, other.str_); return *this; } void fun(char *&a)//1 metherd { a = (char *)malloc(128 * sizeof(char)); memset(a, ‘E’, 128 * sizeof(char)); } void fun1(char **a)//2 metherd { *a = (char *)malloc(128 * sizeof(char)); memset(*a, ‘E’, 128 * sizeof(char)); } pair<int, int> get_target_up(vector vec, int target) { map<int, int> mapint; pair<int, int> res; for (int i = 0; i < vec.size(); i++) { auto iter = mapint.find(vec[i]); if (iter != mapint.end()) { res.first = iter->second; res.second = i; return res; } mapint[target - vec[i]] = i; } } int main() { /test 1/ A a; cout << a.a<<" “<< a.b<<” "<< a.c << endl; /test 2/ MyString mys(“abcdf”, 12); mys.printch(); MyString mys1 = mys; mys1.printch(); char ch[4] = “123”; cout << sizeof(ch) << " " << strlen(ch) << endl; /test 3/ char *astr = NULL; fun1(&astr); cout << astr[50] << endl; /test 4/ pair<int, int> res = get_target_up(vector{3,3}, 6); cout << res.first << " " << res.second << endl; system(“pause”); return 0; }