Share xc++2015

tamnguyetlythuc

New member
** #xc ++ 2015 #c ++ #Programming #tutorial #tham chiếu **

## x ++ 2015: Hướng dẫn của người mới bắt đầu

C ++ 2015 là bản phát hành chính mới nhất của ngôn ngữ lập trình C ++.Nó giới thiệu một số tính năng mới làm cho nó mạnh mẽ và biểu cảm hơn các phiên bản trước.

Hướng dẫn này sẽ cung cấp cho bạn một giới thiệu nhẹ nhàng về C ++ 2015. Chúng tôi sẽ đề cập đến những điều cơ bản của ngôn ngữ, bao gồm các kiểu dữ liệu, biến, câu lệnh lưu lượng kiểm soát và các chức năng.Chúng tôi cũng sẽ xem xét một số tính năng mới trong C ++ 2015, chẳng hạn như biểu thức Lambda, ConsexPR và dựa trên phạm vi cho Loop.

Đến cuối hướng dẫn này, bạn sẽ hiểu rõ về ngôn ngữ C ++ 2015 và có thể viết các chương trình của riêng bạn.

### Bắt đầu

Điều đầu tiên bạn cần làm là cài đặt trình biên dịch C ++.Có một số trình biên dịch khác nhau có sẵn, nhưng đối với hướng dẫn này, chúng tôi sẽ sử dụng [tiện ích mở rộng Visual Studio Code C ++] (C/C++ - Visual Studio Marketplace).

Khi bạn đã cài đặt trình biên dịch, bạn có thể tạo dự án C ++ mới bằng cách mở mã Visual Studio và chọn tệp **> MỚI> Dự án **.Từ danh sách các mẫu dự án, chọn ** C ++> Dự án trống **.

Điều này sẽ tạo một thư mục dự án mới với một tệp `main.cpp` duy nhất.Bạn có thể mở tệp này và bắt đầu viết mã của bạn.

### Những điều cơ bản của C ++

Các khối xây dựng cơ bản của C ++ là các loại dữ liệu, biến và biểu thức.

** Kiểu dữ liệu ** Xác định loại dữ liệu mà một biến có thể lưu trữ.Các loại dữ liệu phổ biến nhất là số nguyên, số điểm nổi và ký tự.

** Biến ** được sử dụng để lưu trữ dữ liệu.Để khai báo một biến, bạn sử dụng cú pháp sau:

`` `C ++
int my_varable;
`` `

Điều này tuyên bố một biến có tên là `my_varable` loại` int`.

** Biểu thức ** được sử dụng để đánh giá các giá trị.Các biểu thức phổ biến nhất là các biểu thức số học, thực hiện các hoạt động toán học trên các toán hạng.

Ví dụ: biểu thức sau đây cộng hai số lại với nhau:

`` `C ++
int x = 10 + 20;
`` `

### Báo cáo lưu lượng điều khiển

Kiểm soát các câu lệnh cho phép bạn kiểm soát thứ tự thực hiện mã của bạn.Các câu lệnh dòng điều khiển phổ biến nhất là `if`,` other`, `for` và` while.

** Nếu các câu lệnh ** được sử dụng để thực thi mã nếu một điều kiện nhất định là đúng.Mã sau in tin nhắn "Xin chào thế giới!"Nếu biến `x` bằng 10:

`` `C ++
if (x == 10) {
std :: cout << "Xin chào thế giới!"<< std :: endl;
}
`` `

** Các câu lệnh khác ** được sử dụng để thực thi mã nếu điều kiện trong câu lệnh `if` là sai.Mã sau đây in tin nhắn "Goodbye World!"Nếu biến `x` không bằng 10:

`` `C ++
if (x! = 10) {
std :: cout << "Tạm biệt Thế giới!"<< std :: endl;
}
`` `

** Đối với các vòng lặp ** được sử dụng để thực thi một khối mã một số lần được chỉ định.Mã sau in các số từ 1 đến 10:

`` `C ++
for (int i = 0; i <10; i ++) {
std :: cout << i << std :: endl;
}
`` `

** Trong khi các vòng lặp ** được sử dụng để thực thi một khối mã trong khi một điều kiện nhất định là đúng.Mã sau in các số từ 1 đến 10, nhưng nó dừng nếu người dùng nhấn phím `enter`:

`` `C ++
int i = 0;
while (true) {
std :: cout << i << std :: endl;

if (std :: cin.get () == '\ n') {
phá vỡ;
}

i ++;
}
`` `

### Mới
=======================================
**#XC++2015 #C++ #Programming #tutorial #Reference**

## X++ 2015: A Beginner's Guide

C++ 2015 is the latest major release of the C++ programming language. It introduces a number of new features that make it more powerful and expressive than previous versions.

This tutorial will provide you with a gentle introduction to C++ 2015. We'll cover the basics of the language, including data types, variables, control flow statements, and functions. We'll also look at some of the new features in C++ 2015, such as lambda expressions, constexpr, and the range-based for loop.

By the end of this tutorial, you'll have a solid understanding of the C++ 2015 language and be able to write your own programs.

### Getting Started

The first thing you need to do is install a C++ compiler. There are a number of different compilers available, but for this tutorial we'll be using the [Visual Studio Code C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).

Once you have installed the compiler, you can create a new C++ project by opening Visual Studio Code and selecting **File > New > Project**. From the list of project templates, select **C++ > Empty Project**.

This will create a new project folder with a single `main.cpp` file. You can open this file and start writing your code.

### Basics of C++

The basic building blocks of C++ are data types, variables, and expressions.

**Data types** define the type of data that a variable can store. The most common data types are integers, floating-point numbers, and characters.

**Variables** are used to store data. To declare a variable, you use the following syntax:

```c++
int my_variable;
```

This declares a variable named `my_variable` of type `int`.

**Expressions** are used to evaluate values. The most common expressions are arithmetic expressions, which perform mathematical operations on operands.

For example, the following expression adds two numbers together:

```c++
int x = 10 + 20;
```

### Control Flow Statements

Control flow statements allow you to control the order in which your code is executed. The most common control flow statements are `if`, `else`, `for`, and `while`.

**If statements** are used to execute code if a certain condition is true. The following code prints the message "Hello world!" if the variable `x` is equal to 10:

```c++
if (x == 10) {
std::cout << "Hello world!" << std::endl;
}
```

**Else statements** are used to execute code if the condition in an `if` statement is false. The following code prints the message "Goodbye world!" if the variable `x` is not equal to 10:

```c++
if (x != 10) {
std::cout << "Goodbye world!" << std::endl;
}
```

**For loops** are used to execute a block of code a specified number of times. The following code prints the numbers from 1 to 10:

```c++
for (int i = 0; i < 10; i++) {
std::cout << i << std::endl;
}
```

**While loops** are used to execute a block of code while a certain condition is true. The following code prints the numbers from 1 to 10, but it stops if the user presses the `Enter` key:

```c++
int i = 0;
while (true) {
std::cout << i << std::endl;

if (std::cin.get() == '\n') {
break;
}

i++;
}
```

### New
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top