C++ Primer Plus 第4章 习题8

#include <iostream>
#include <string>

struct Pizza
{
	std::string company;
	double diameter;
	double weight;
};

int main()
{
	Pizza* ppizza = new Pizza;
	std::cout << "请输入pizza的信息:" << std::endl;
	std::cout << "pizza的直径是:" << std::endl;
	std::cin >> ppizza->diameter;
	std::cin.get();

	std::cout << "pizza的生产公司是:" << std::endl;
	//std::cin.getline(ppizza->company);
	getline(std::cin, ppizza->company, '\n');

	std::cout << "pizza的重量为:";
	std::cin >> ppizza->weight;

	std::cout << "pizza的公司是:" << ppizza->company << ". " << std::endl;
	std::cout << "pizza的直径是:" << ppizza->diameter << std::endl;
	std::cout << "pizza的重量是:" << ppizza->weight << std::endl;

	delete ppizza;


	return 0;
}

 

上一篇:C++ Primer 指针,引用笔记


下一篇:《C++primer》学习:第二章(笔记及程序设计练习)