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

📄 testnewstring.cpp

📁 这是学习《Data Structures Using C++》
💻 CPP
字号:
//Test Program
#include <iostream>
#include <cstring>
#include "newString.h"

using namespace std;

int main()
{
	newString s1 = "Sunny"; 	//Initialize s1 using 
							//the assignment operator 
	const newString s2("Warm"); 	//Initialize s2 using 
 								//the conversion constructor
	newString s3;  //Initialize s3 to null
	newString s4;  //Initialize s4 to null

	cout<<"Line 1: "<<s1<<"    "<<s2<<"  ***"
		<<s3<<"###."<<endl; 							//Line 1

	if(s1 <= s2)     		      	//Compare s1 and s2; Line 2
		cout<<"Line 3: "<<s1<<" is less than or equal to "<<s2
			<<endl; 									//Line 3
	else												//Line 4
		cout<<"Line 5: "<<s2<<" is less than "<<s1
			<<endl; 									//Line 5

	cout<<"Line 6: Enter a string that has "
		<<"at least 7 characters --> ";  				//Line 6
	cin>>s1;         							//input s1; Line 7
	cout<<endl<<"Line 8: New value of s1 = "<<s1
		<<endl;   		 								//Line 8

	s4 = s3 = "Birth Day"; 								//Line 9
	cout<<"Line 10: s3 = "<<s3<<", s4 = "<<s4<<endl;  	//Line 10

	s3 = s1;  											//Line 11
	cout<<"Line 12: The new value of s3 = "<<s3<<endl;	//Line 12

	s1 = "Bright Sky";  								//Line 13

	s3[1] = s1[5];										//Line 14
	cout<<"Line 15: After replacing the second character of s3 = "
		<<s3<<endl; 									//Line 15

	s3[2] = s2[3];				  						//Line 16
	cout<<"Line 17: After replacing the third character of s3 = "
		<<s3<<endl; 									//Line 17

	s3[5] = 'g'; 										//Line 18
	cout<<"Line 19: After replacing the sixth character of s3 = "
		<<s3<<endl; 									//Line 19

	return 0;
}

⌨️ 快捷键说明

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