https://tlanyan.pp.ua/cpp-function-modifier-summary/
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14
typedef int myint
int main(){
const int sz = get_size(); //const objects: must be initialized when created. Not a const expression
constexpr int num = 315; //constant expression: value canbe evaluated at complie time
int arr[num]; //array dimension (as part of the array's type) must be know at compile time
/* array
** int a2[] = a1; //error: cannot initialize one array with another
** int *ptr[10]; //array of ten pointers to int
** int (*Ptr)[10] = &arr //point to an array of ten ints
*/
return 0;
}
Static与Const的区别
C++ static、const 和 static const 类型成员变量声明以及初始化
const
- const 成员变量也不能在类定义处初始化,只能通过构造函数初始化列表进行,并且必须有构造函数
static
- outside the class, do not repeat the
statickeyword;static member functionsdo not havethispointer, may not be declared asconst;static data membersare not initialized by the constructors, they are usually defined and initialized outside the class body. (const integral type can be initialized inside the class body)static data memberscan be the class, whereas nonstatic data members must be declared as pointers or references to the class;static data memberscan be used as default argument