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

📄 mains.cpp

📁 This a Vector Class overloading operator >>,<<,+,-,*,=,! 2 vector
💻 CPP
字号:
#include <iostream.h>
#include <iomanip.h>
#include "strings.h"
#include <assert.h>
int main()
{
	Strings S1("happy"), S2(" birthday"), S3;
	cout << "S1 is \"" << S1 << "\"; S2 is \"" << S2
		  << "\"; S3 is \"" << S3 << '\"' << endl
		  << "The results of comparing S2 and S1:" << endl
		  << "S2 == S1 yields " << (S2 == S1) << endl
		  << "S2 != S1 yields " << (S2 != S1) << endl
		  << "S2 >  S1 yields " << (S2 > S1) << endl
		  << "S2 <  S1 yields " << (S2 < S1) << endl
		  << "S2 >= S1 yields " << (S2 >= S1) << endl
		  << "S2 <= S1 yields " << (S2 <= S1) << endl;
	cout << "Testing !S3:" << endl;
	if (!S3)
	{
		cout << "S3 is empty; assigning S1 to S3;" << endl;
		S3 = S1;
		cout << "S3 is \"" << S3 << "\"" << endl;
	}
	cout << "S1 += S2 yields S1 = ";
	S1 += S2;
	cout << S1 << endl;
	cout << "S1 += \" to you\" yields" << endl;
	S1 += " to you";
	cout << "S1 = " << S1 << endl;
	cout << "The substring of S1 starting at" << endl
		  << "location 0 for 14 characters, S1(0, 14), is: "
		  << S1(0, 14) << endl;
	cout << "The substring of S1 starting at" << endl
		  << "location 15, S1(15, 0), is: "
		  << S1(15, 0) <<endl;  // 0 is "to end of string"
	Strings *S4Ptr = new Strings(S1);
	cout << "*S4Ptr = " << *S4Ptr <<endl;
	cout << "assigning *S4Ptr to *S4Ptr" << endl;
	*S4Ptr = *S4Ptr;
	cout << "*S4Ptr = " << *S4Ptr << endl;
	delete S4Ptr;
	S1[0] = 'H';
	S1[6] = 'B';
	cout <<"S1 after S1[0] = 'H' and S1[6] = 'B' is: "<< S1 << endl;
	cout << "Attempt to assign 'd' to S1[30] yields:" << endl;
	//S1[30] = 'd'; //Loi: Chi so vuot khoi mien!!!
	return 0;
}

⌨️ 快捷键说明

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