栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

C++基础1---C++入门

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

C++基础1---C++入门

学习网站:C语言网.
C语言基础:C语言基础.
编译器:Red Panda Dev-C++



1.第一个C++程序
#include 		// 文件包含;包含iostream标准库; 
using namespace std;	// 声明使用一个叫std命名空间; 
int main(){
	cout << "Hello World." << endl;
	cout << "Welcome to the C++ world." << endl;
	return 0;
}
2.命名空间
// 1.命名空间:解决多个模块间命名冲突的问题;
#include 
using namespace std;
int main(){
    cout << "Hello C++." << endl;
    return 0;
}

// 2.域限定符::
#include 
int main(){
    std::cout << "Hello C++." << std::endl;
    return 0;
}

// 3.用using和域限定符一起限定用哪些名字
#include 
using std::cout;
using std::endl;
int main(){
    cout << "Hello C++." << std::endl;
    return 0;
}
3.输入输出
// 1.C++输入输出可以使用printf和scanf函数实现;
// 2.C++输入输出流使用cin和cout表示,使用前需要包含标准库iostream;
#include 
using namespace std;
int main(){
    cout << "Hello C++." << endl;	// endl起到换行作用;
    cout << "Welcome to FUXI." << "I am Willard." << endl;
    return 0;
}
// cin输入流:接收一个数据前,先定义一个与之类型一致的变量,用来存放这个数据
// 然后利用cin搭配>>输入操作符,来接收用户从键盘的输入;
#include 
using namespace std;
int main(){
	int numberOne;
	int numberTwo;
	
	cout << "Please input one number:" << endl;
	cin >> numberOne >> numberTwo;
	
	cout << "The value of numberOne is:" << numberOne << endl;
	cout << "The value of numberTwo is:" << numberTwo << endl;
	
	return 0;
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/863982.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号