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

从零开始的c++旅程(1)软件与头文件

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

从零开始的c++旅程(1)软件与头文件

在互联网技术突飞猛进的时代,计算机逐渐占据了生活的主要地位

而编程则是构成这个美好时代的根源

c++是一种基础代码,易上手

他还是c语言的改版

下载一个c++(新手建议用dev,因为他很小巧)

点击箭头位置,新建一个源代码

这样你就可以写代码了

输入这一段代码

#include 
using namespace std;
int main(){

	return 0;
}

第一行为头文件

#include 

大家把它称作万能头文件

它虽然只有小小一段,但却包含着很多东西

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// .



// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include 
#endif
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#if __cplusplus >= 201103L
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#endif

// C++
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#if __cplusplus >= 201103L
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#endif

这些是万能头文件所包含的

但前期不建议用,因为它包含一些你不需要的东西

第2行是命名空间

using namespace std;

这是用于申请变量空间的

有了它,你才能应用变量

接下来便是主函数

int main(){

	return 0;
}

这是我们写操作的地方

主函数意味着建立一个独立进程,既是程序的入口,又是程序的出口

有的人可能就问了:有主函数,那有没有其他函数呢?

当然有,在后面的博客里,我会陆续提到

程序执行总是从主函数开始,如果有有其他函数,则完成对其他函数的调用后再返回到主函数,最后由main函数结束整个程序。在执行程序时,由系统调用main函数。

那return 0;是什么意思呢?

return 0 代表程序正常退出。. return是C++预定义的语句,它提供了终止函数执行的一种方式。. 当return语句提供了一个值时,这个值就成为函数的返回值。. return语句用来结束循环,或返回一个函数的值。



 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1012969.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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