当前位置:网站首页>22. [static member access format] class name:: access member, then the member needs to be static]
22. [static member access format] class name:: access member, then the member needs to be static]
2022-07-21 20:45:00 【Li is struggling】
【 Static members are available 】
#include <iostream>
using namespace std;
class Student
{
public:
int age;
int number;
Student(int a, int nu) :age(a), number(nu) {}
Student() {}
void set()
{
cout << " Please enter the student's age and student number " << endl;
cin >> age >> number;
}
static void show()
{
cout << " The age of the students is :" << " " << " The student number is :" << endl;
}
};
int main()
{
Student::show();
return 0;
}
【 Non static unavailable 】
#include <iostream>
using namespace std;
class Student
{
public:
int age;
int number;
Student(int a, int nu) :age(a), number(nu) {}
Student() {}
void set()
{
cout << " Please enter the student's age and student number " << endl;
cin >> age >> number;
}
static void show()
{
cout << " The age of the students is :" << " " << " The student number is :" << endl;
}
};
int main()
{
Student::set();
return 0;
}
边栏推荐
猜你喜欢
Upload pictures and avatars
XML parsing
12. [i/o flow get() and getline() and put() functions]
MySQL之函数
OpenFoam中的VOF相变方程
Recommander un éditeur de markdown facile à utiliser Mark Text
Cannot read property mode of undefined
增删改查~
Don't pull it today, don't pull it, read it in pieces
10. [file opening format and its determination of whether to open]
随机推荐
Hot update in development mode to speed up the code update of development environment
固体火箭发动机零维内弹道方程组
Realization of serpentine digital lattice Write a cube function with the input parameter of num. the requirements are as follows through JS: when num=3, the output table effect is: [[1,2,3] [6,5,4] [7
Self taught programming for more than 80 years, these private practical tools & learning websites have accompanied me to the present. I must collect them and double my learning efficiency - Website
The C language header stdio cannot be found after Xcode upgrade H solution
Global variable configuration dev . dev.dev . dev.test
Format time
swift 导航栏颜色设备和去掉下边缘线
How to get the second child element under the first child element
计算传热学基础
QML implements CSDN search box with irregular rounded corners
16. [assignment of string ends with semicolon]
14. [string function Chapter 1]
Add, delete, modify and check~
Jump and receive parameters of JS page
Data analysis on the fourth match
uni-app 新建报错 Cannot read property mode of undefined
[c language] light rises in the dull days, the initial stage and the final battle
Don't pull it today, don't pull it, read it in pieces
express+ejs+swagger-ui-dist 打造及时更新的rest api 在线接口文档