⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 一本语言类编程书籍
💻 CPP
字号:
// Exercise 14.2 Concatenating and appending strings.
// We will add prototypes for overloaded + and += operators to the MyString class.
// Note that the argument and return values to the += operator functions are references.

#include "MyString.h"
#include <iostream>
using std::cout;
using std::endl;
using mySpace::MyString;          // Using declaration

int main() {
  MyString s1;
  MyString s2("Abu ");
  MyString s3("Ben ");
  cout << "\n s2 is: ";
  s2.show();
  cout << "\n s3 is: ";
  s3.show();

  s1 = s2+s3;                     // Try out addition

  cout << "\n After executing s1 = s2+s3, s1 is: ";
  s1.show();

  s3 = MyString("Adam");
  cout << "\n\n s3 is: ";
  s3.show();
  s1 += s3; 
  cout << "\n After executing s1 = s2+s3, s1 is: ";
  s1.show();

  cout << endl;

  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -