没有合适的资源?快使用搜索试试~ 我知道了~
首页C++入门教程:从零开始到环境配置
C++入门教程:从零开始到环境配置
需积分: 13 9 下载量 32 浏览量
更新于2024-07-24
1
收藏 3.53MB PDF 举报
"Jumping into C++" 是一份全面且深入的C++编程教程,专为初学者设计,旨在帮助读者掌握C++语言的基础知识以及如何设置开发环境。作者强调,尽管教程是英文版,但对于完全没有C++经验的读者来说,它也易于上手,无需事先了解C语言。 章节1介绍了编程语言的基本概念,解释了C与C++之间的区别,指出学习C++并非必须先懂C,但了解一些基本概念是有益的。章节中还涵盖了编程术语的解释,如可执行文件、编辑源代码和编译过程,以及针对Windows、Macintosh(使用Xcode)和Linux(使用g++)平台的具体安装和运行步骤。每一步都提供了详尽的操作指南,并对可能出现的问题提供了故障排除方法。 在Chapter 2,"The Basics of C++" 中,作者详细介绍了C++语言的入门知识。读者会了解到C++程序的基本结构,通过一个简单的示例来理解程序的工作原理。这部分内容包括变量、数据类型、控制结构(如if-else语句和循环)以及函数的基础使用。 此外,作者还强调了阅读和理解样本源代码的重要性,以加深对理论知识的理解。教程鼓励读者亲手实践,通过创建和运行自己的第一个C++程序来巩固所学。无论是新手还是有一定基础的学习者,这份教程都能提供清晰的指导路径,帮助他们在C++的世界里迈出坚实的第一步。 "Jumping into C++" 是一本既适合自学又适合作为教学资源的实用教程,它不仅涵盖了C++语言的入门知识,还提供了实际操作的步骤,让学习者能够快速熟悉并开始编写自己的C++程序。无论是对于想要入门C++的初学者,还是希望提升现有技能的开发者,都是一个不容错过的宝贵资源。
资源详情
资源推荐
© Alex Allain (www.cprogramming.com)
14
Terminology
Throughout the book, I’ll be defining new terms, but let’s get started with some very basic concepts that
you’ll need to get started.
Programming
Programming is the act of writing instructions in a way that allows a computer to understand and
execute those instructions. The instructions themselves are called source code. That's what you'll be
writing. We'll see some source code for the very first time in a few pages.
Executable
The end result of programming is that you have an executable file. An executable is a file that your
computer can run—if you’re on Windows, you’ll know these files as EXEs. A computer program like
Microsoft Word is an executable. Some programs have additional files (graphics files, music files, etc.)
but every program requires an executable file. To make an executable, you need a compiler, which is a
program that turns source code into an executable. Without a compiler, you won’t be able to do
anything except look at your source code. Since that gets boring quickly, the very next thing we will do is
set you up with a compiler.
Editing and compiling source files
The rest of this chapter is devoted to getting you set up with a simple, easy-to-use development
environment. I'll get you set up with two specific tools, a compiler and an editor. You've already learned
why you need a compiler—to make the program do stuff. The editor is less obvious, but equally
important: an editor makes it possible for you to create source code in the right format.
Source code must be written in a plain text format. Plain text files contain nothing but the text of the
file; there is no additional information about how to format or display the content. In contrast, a file you
produce using Microsoft Word (or similar products) is not a plain text file because it contains
information about the fonts used, the size of the text, and how you’ve formatted the text. You don’t see
this information when you open the file in Word, but it’s all there. Plain text files have just the raw text,
and you can create them using the tools we're about to discuss.
The editor will also give you two other nice features, syntax highlighting and auto-indentation. Syntax
highlighting just means it adds color coding so that you can easily tell apart different elements of a
program. Auto-indentation means that it will help you format your code in a readable way.
If you're using Windows or a Mac, I'll get you set you up with a sophisticated editor, known as an
integrated development environment (IDE) that combines an editor with a compiler. If you're using
Linux, we'll use an easy-to-use editor known as nano. I'll explain everything you need in order to get set
up and working!
A note about sample source code
This book includes extensive sample source code, all of which is made available for you to use, without
restriction but also without warranty, for your own programs. The sample code is included in
sample_code.zip, which came with this book. All sample source code files are stored in a separate
folder named after the chapter in which that source file appears (e.g. files from this chapter appear in
the folder ch1). Each source code listing in this book that has an associated file has the name (but not
the chapter) of the file as a caption.
© Alex Allain (www.cprogramming.com)
15
Windows
We’ll set up a tool called Code::Blocks, a free development environment for C++.
Step 1: Download Code::Blocks
• Go to this website: http://www.codeblocks.org/downloads
• Follow the link to "Download the binary release" (direct link)
• Go to the Windows 2000 / XP / Vista / 7 section
• Look for the file that includes mingw in the name. (The name as of this writing was codeblocks-
10.05mingw-setup.exe; the number may be different).
• Save the file to your desktop. As of this writing, It is roughly 74 megabytes.
Step 2: Install Code::Blocks
• Double click the installer.
• Hit next several times. Other setup tutorials will assume you have installed in C:\Program
Files\CodeBlocks (the default install location), but you may install elsewhere if you like
• Do a Full Installation (select "Full: All plugins, all tools, just everything" from the "Select the type
of install" dropdown menu)
• Launch Code::Blocks
Step 3: Running Code::Blocks
You will be prompted with a Compilers auto-detection window:
When you get the compiler auto-detection window, just hit OK. Code::Blocks may ask if you want to
associate it as the default viewer for C/C++ files—I suggest you do. Click on the File menu, and under
"New", select "Project..."
© Alex Allain (www.cprogramming.com)
16
The following window will come up:
Click on "Console Application" and hit the "Go" button. All sample code from this book can be run as a
console application.
© Alex Allain (www.cprogramming.com)
17
Click next until you get to the Language Selection Dialog:
You'll be asked to choose whether you want to use C or C++. Since we’re learning C++, pick C++.
© Alex Allain (www.cprogramming.com)
18
After clicking "Next", Code::Blocks will then prompt you with where you'd like to save the console
application:
I'd recommend you put it in its own folder, as it may create several files (this is especially true if you
create other types of projects). You will need to give your project a name; anything will be fine.
剩余382页未读,继续阅读
MrJGao
- 粉丝: 702
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 构建Cadence PSpice仿真模型库教程
- VMware 10.0安装指南:步骤详解与网络、文件共享解决方案
- 中国互联网20周年必读:影响行业的100本经典书籍
- SQL Server 2000 Analysis Services的经典MDX查询示例
- VC6.0 MFC操作Excel教程:亲测Win7下的应用与保存技巧
- 使用Python NetworkX处理网络图
- 科技驱动:计算机控制技术的革新与应用
- MF-1型机器人硬件与robobasic编程详解
- ADC性能指标解析:超越位数、SNR和谐波
- 通用示波器改造为逻辑分析仪:0-1字符显示与电路设计
- C++实现TCP控制台客户端
- SOA架构下ESB在卷烟厂的信息整合与决策支持
- 三维人脸识别:技术进展与应用解析
- 单张人脸图像的眼镜边框自动去除方法
- C语言绘制图形:余弦曲线与正弦函数示例
- Matlab 文件操作入门:fopen、fclose、fprintf、fscanf 等函数使用详解
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功