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

📄 prg4_1.cpp

📁 这是数据结构和算法的国外经典书籍.清华大学出版社出版的<数据结构C++语言描述-应用模板库STL>陈君 译 英文名称是Data Structures with C++ Using 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 "stdafx.h"
#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),r=6;
	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 << r << 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 + -