Our C++ (basic) (in English)

What's C++?

C++ is a high-level language . It was designed and developed by Bjarne Stroustrup in 1979 at Bell Labs. C++ is an object-oriented programming language that expands and improves the C language. C++ runs on a variety of platforms, such as Windows, MAC operating systems, and UNIX versions.

C++ is a statically typed, compiled, general-purpose, case-sensitive, irregular programming language that supports procedural, object-oriented, and generic programming.

C++ is considered an intermediate-level language that combines the characteristics of a high-level language with a low-level language.

C++ was designed and developed by Bjarne Stroustrup in 1979 at Bell Labs, Mount Merry, New Jersey. C++ further expanded and refined the C language, initially named C with classes, and later renamed C++ in 1983.

C++ is a superset of C, and in fact, any legitimate C program is a legitimate C++ program.

Note: Programming languages that use static types perform type checking at compile time, not at runtime.

C++ syntax

A C++ program can be defined as a collection of objects that interact with each other by calling each other's methods. Now let's take a brief look at what a class, an object, a method, an instant variable is.

Object

An object has a state and a behavior. For example: the state of a dog - color, name, breed,

behavior

shake, bark, eat. An object is an instance of a class.

Classes

Classes can be defined as templates/blueprints that describe the behavior/state of an object.

Method

Basically, a method represents a behavior. A class can contain multiple methods. You can write logic, manipulate data, and perform all actions in a method.

Instant Variables

Each object has its own unique instant variables. The state of an object is created by the values of these instant variables.

An easy C++ code

#include <iostream>
using namespace std;
 
// using namespace std is the beginning of the code
 
int main()
{
   cout << "Hello World"; // output Hello World
   return 0;
}

Type of data

Boolean       bool
Character    char
integer           int
floating-point float
Double floating-point double
Untyped void

The type of data
Booleanbool
Characterchar
Integerint
Floating-pointfloat
Double floating-pointdouble
Untypedvoid
Note:long long's limit is bigger than long's limit than int's limit.

Input & output in C++

Input

//When you want to input something, you should use one of them. (sort by time spent) (from big to small)
For example, if you want to input an integer x, you can use them.  
cin >> x;
scanf("%d",&x);
/*
When you input in "scanf", you should be careful, because the different type of data have different way to input.
For example, if you want to input x, if the data type of x is one of them, you should:
    type                      way to input
1.long long                 scanf("%lld",&x);
2.long                      scanf("%ld",&x);
3.int                       scanf("%d",&x);
4.char                      scanf("%c",&x);
5.double                    scanf("%lf",&x);
6.float                     scanf("%f",&x);
7.string                    scanf("%s",&x);
8.Octadecimal integer       scanf("%o",&x);
9.Hexadecimal integer       scanf("%c",&x);
10.None                     scanf("%*",&x);

output

//If you want to output an integer x, you should use one of them.
cout<<x;
printf("%d",&x);
//Precautions of output is similar to precautions of input.

  • 27
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值