摘要:
c++内联函数 先放语法: inline int max(int a,int b) { return a > b ? a : b ; } //先声明后定义 void Foo(int x, int y); inline void Foo(int x, int y) {} // inline 与函数定义 阅读全文
posted @ 2021-01-21 07:48
未徙
阅读(87)
评论(0)
推荐(0)
摘要:
C++类成员的访问权限以及类的封装 访问权限 c++中提供了三种成员访问限定符: public:公有 private:私有 protected:受保护 Java、C# 程序员注意,C++ 中的 public、private、protected 只能修饰类的成员,不能修饰类,C++中的类没有共有私有之 阅读全文
posted @ 2021-01-21 07:46
未徙
阅读(398)
评论(0)
推荐(0)
摘要:
C++构造函数详解 先放语法: class obj{ private: int m_data1; int m_data2; char* m_name; public: obj(int data1,int data2,char* name); }; //构造函数,析构函数,拷贝构造函数都应该声明为pu 阅读全文
posted @ 2021-01-21 07:45
未徙
阅读(472)
评论(0)
推荐(0)
摘要:
c++析构函数 先放语法: class VLA{ public: VLA(char* arr); //构造函数 ~VLA(); //析构函数 public: void input(); //从控制台输入数组元素 void show(); //显示数组元素 private: char *m_arr; 阅读全文
posted @ 2021-01-21 07:44
未徙
阅读(215)
评论(0)
推荐(0)
摘要:
C++ this指针详解 先放语法: class Student{ public: void setname(char *name); void setage(int age); void setscore(float score); private: char *name; int age; fl 阅读全文
posted @ 2021-01-21 07:42
未徙
阅读(212)
评论(0)
推荐(0)
摘要:
C++ static静态成员变量详解 先放语法: class Student{ public: static int m_total;//静态成员变量 }; 对象的内存中包含了成员变量,不同的对象占用不同的内存(已在《C++对象的内存模型》中提到),这使得不同对象的成员变量相互独立,它们的值不受其他 阅读全文
posted @ 2021-01-21 07:40
未徙
阅读(300)
评论(0)
推荐(0)
摘要:
C++ static静态成员函数详解 先放语法: class Student{ public: static int m_total; public: static int get_m_total(); }; int Student::get_m_total() { return m_total; 阅读全文
posted @ 2021-01-21 07:38
未徙
阅读(1094)
评论(0)
推荐(0)
摘要:
C++ const成员变量和成员函数(常成员函数) 在类中,如果你不希望某些数据被修改,可以使用const关键字加以限定。const 可以用来修饰成员变量和成员函数。 const成员变量 const 成员变量的用法和普通 const 变量的用法相似,只需要在声明时加上 const 关键字。初始化 c 阅读全文
posted @ 2021-01-21 07:37
未徙
阅读(256)
评论(0)
推荐(0)
摘要:
C++ const对象(常对象) 在 C++ 中,const 也可以用来修饰对象,称为常对象。一旦将对象定义为常对象之后,就只能调用类的 const 成员(包括 const 成员变量和 const 成员函数)了。 定义常对象的语法和定义常量的语法类似: const class object(para 阅读全文
posted @ 2021-01-21 07:36
未徙
阅读(153)
评论(0)
推荐(0)
摘要:
C友元函数和友元类(C friend关键字) 先放语法: //非成员函数声明为友元函数 class Student{ public: friend void show(Student *pstu); private: int data; }; void show(Student *pstu) { c 阅读全文
posted @ 2021-01-21 07:35
未徙
阅读(226)
评论(0)
推荐(0)

浙公网安备 33010602011771号