-->
当前位置:首页 > 题库

PROGRAMMING:The custom class mystring implements the operator = overload

Luz5年前 (2021-05-10)题库445
User defined string class mystring, including private member variable char * buf; Member functions include: nonparametric constructor (outputting "construct 0"), parametric constructor (outputting "construct 1"), destructor (outputting "destruct"), outputting function, and overloading operator = (using functions like mystring, strcpy and strcat respectively, adding keyboard input string information after "C + +"); Two mystring class objects, STR1 (CH) and STR2, are defined in main(), where ch is a character array (assigned value by inputting character information from keyboard), and STR2 = STR1 is directly used; The information in STR2 is assigned to the connection result of "C + +" and the string in STR1, and the string of STR1 and STR2 are output respectively.
###Input format:
Give a string with no more than 50 characters in one line.
###Output format:
The prompt information of construction and deconstruction is output respectively, and the values of STR1 and STR2 are output respectively in the two lines.
###Input example:
Here is a set of inputs. For example:
```in
hello
```
###Output example:
The corresponding output is given here. For example:
```out
construct 1
hello
construct 0
c++hello
destruct
destruct
```







answer:If there is no answer, please comment