随笔分类 - C++学习
部分C++笔记,不成熟
摘要://#include<iostream> //using namespace std; // //class Stu //{ //public: // int temp; // Stu(int t) // { // temp = t; // } // //负号 // int operator-()
阅读全文
摘要://#include<iostream> //using namespace std; // //class Stu //{ //public: // int a; // Stu(int a1) // { // a = a1; // } // //关系运算符重载 // int operator>=(
阅读全文
摘要://#include<iostream> //using namespace std; // //class Stu //{ //public: // int a; // Stu() // { // a = 26; // } // int operator+(int b) //在类内重载,左边参数若
阅读全文
摘要://#include<iostream> //using namespace std; // // //class Stu //{ //public: // int a; // double b; // // Stu() // { // a = 12; // b = 13.13; // } //};
阅读全文
摘要://#include<iostream> //using namespace std; // //#define SUM(x) ((x)*(x)) //定义一个宏参数 // // //inline void fun(int i) //{ // cout << (i * i); // //} // /
阅读全文
摘要://#include<iostream> //using namespace std; // //class Stu //{ //public: // int *a; // Stu() // { // a = new int[2]; // a[0] = 13; // a[1] = 12; // }
阅读全文
摘要://#include<iostream> //using namespace std; // //class Stu //{ //public: // int b; // char c[4]; // Stu() //构造函数 // { // b = 4; // c[0] = 'a'; // strc
阅读全文
摘要://#include<iostream> //using namespace std; // //class Stu //{ //public: // static int b; //静态成员无论赋值如何变化,一个静态成员只有一个空间 // Stu() // { // b++; // } // //
阅读全文
摘要://#include<iostream> //using namespace std; // //class Ten //{ //private: // static int c; //当静态成员函数在私有成员下定义,类外不可对其进行访问 //public: // static int a; //静
阅读全文
摘要://#include<iostream> //using namespace std; // //class Seven //{ //public: // //构造函数和析构函数不能定义为常函数 // int a; // // Seven() // { // a = 12; // } // // ~
阅读全文
摘要://#include<iostream> //using namespace std; // //class Six //{ //public: // int a; // Six(int a) // { //用this指针来区分局部变量和成员变量 // this->a = a; //this指针对应
阅读全文
摘要://#include<iostream> //using namespace std; // //class Five //{ //public: // int n; // Five() //定义一个构造函数 // { // cout << "调用构造函数" << endl; // } // //
阅读全文
摘要://#include<iostream> //using namespace std; // //class Stu //{ //public: // int age; // float f; // //构造函数,可由系统自动调用 // Stu() //一个类中可存在多个构造函数,多个构造函数构成重
阅读全文
摘要://#include<iostream> //using namespace std; // //class Stu //{ //public: // int age; // float f; // //构造函数,可由系统自动调用 // Stu() //构造函数的函数名与类名相同,构造函数没有返回值
阅读全文
摘要://#include<iostream> //using namespace std; // //class Stu //{ //protected: //private: // int age; // void fun() // { // age = 12; // cout << age << e
阅读全文
摘要://#include<iostream> //using namespace std; // //class Three //{ //private: // int a; //public: // //protected: //protected在类外不可见 // //仅可在自己所在的类和自己所在类
阅读全文
摘要://#include<iostream> //using namespace std; // //class Second //{ // //访问修饰符的作用,提高代码的安全性 //private://私有成员,只被该类的内部所调用,类内若不写其他的修饰符,则默认privat,在private中的成
阅读全文
摘要://#include<iostream> //using namespace std; // //class First //在C++中,struck结构体是一个特殊的类 // //在类中,默认的访问修饰符为private;在struck结构体中,默认为punlic //{ // //类中要有成员,
阅读全文
摘要://#include<iostream> //using namespace std; //void swap(int& a1, int& b1)//该情况下,将主函数中的a和b分别传递给了a1和b1,在引用的作用下,a和a1,b和b1分别共用一个空间, //{ // int t = a1; //在
阅读全文
摘要://#include<iostream>//using namespace std; // //int& fun()//注意类型要保持一致 //{ // int a = 12;//不能引用局部变量 // return a; //} // //int main() //{ // int& b = fu
阅读全文