神奇的输入输出流
1 2 3 4 5 6 7 8 9 10 11 12 13
| #include <iostream>
int main() { std::cout << "Hello C艹" << std::endl;
std::cout << "Enter tow number:" << std::endl; int v1, v2; std::cin >> v1 >> v2; std::cout << v1 << " + " << v2 << " = " << v1 + v2 << std::endl;
return 0; }
|
面对对象的类
对象操作
Sales_item.h
内容见 Sales_item.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| #include <iostream> #include "Sales_item.h"
int main() { Sales_item book; std::cin >> book; std::cout << book << std::endl;
Sales_item item1, item2; std::cin >> item1 >> item2; if (item1.same_isbn(item2)) { std::cout << item1 + item2 << std::endl; return 0; } else { std::cerr << "Date must refer to same ISBN" << std::endl; }
return 0; }
|