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

📄 prg4_1.cpp

📁 数据结构c++语言描述stl版 威廉兄弟的好书,值得看,这是配书代码
💻 CPP
字号:
// File: prg4_1.cpp
// the program uses the store class to create objects associated
// with int, double, and string types. using the overloaded <<
// operator, it outputs the value in each object. the program
// illustrates the member functions getValue() and setValue()
// for the store object with string data

#include <string>

#include "d_store.h"			// use store class

using namespace std;

int main()
{
	// declare three different types of store objects
	store<int> intStore(5);
	store<double> realStore(2.718);
	store<string> strStore("Template");
	
	cout << "The values stored by the objects are:" << endl;
	cout << intStore << endl;
	cout << realStore << endl;
	cout << strStore << endl;
	cout << endl;

	cout << "The concatenation of 'Template' in strStore and "
			  "'Class' is:" << endl;
	// access current value strStore and concatenate " Class"
	// update the value in strStore with the new string
	strStore.setValue( strStore.getValue() + " Class" );
	cout << strStore << endl;

	return 0;
}

/*
Run:

The values stored by the objects are:
Value = 5
Value = 2.718
Value = Template

The concatenation of 'Template' in strStore and 'Class' is:
Value = Template Class
*/

⌨️ 快捷键说明

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