-
cout 和 cin 都是 C++ 的内置对象,而不是关键字。
C++ 库定义了大量的类(Class),程序员可以使用它们来创建对象,cout 和 cin 就分别是 ostream 和 istream 类的对象,只不过它们是由标准库的开发者提前创建好的,可以直接拿来使用。这种在 C++ 中提前创建好的对象称为内置对象。
-
iostream 是 Input Output Stream 的缩写,意思是“输入输出流”。
-
endl 最后一个字符是字母“l”,而非阿拉伯数字“1”,它是“end of line”的缩写。
#include<iostream>
using namespace std;
int main(){
int x;
float y;
cout<<"Please input an int number and a float number:"<<endl;
cin>>x>>y;
cout<<"The int number is x= "<<x<<endl;
cout<<"The float number is y= "<<y<<endl;
return 0;
}