摘要: //2022年9月9日09:54:59 #include <iostream> using namespace std; class Maker { public: Maker() { cout << "无参构造函数" << endl; } Maker(int a) { cout << "有参构造函 阅读全文
posted @ 2022-09-12 10:53 CodeMagicianT 阅读(31) 评论(0) 推荐(0)
摘要: //2022年9月9日09:21:51 #include <iostream> using namespace std; class Maker { public: //按照参数分类 Maker() { cout << "无参构造" << endl; } Maker(int a) { cout << 阅读全文
posted @ 2022-09-12 10:50 CodeMagicianT 阅读(50) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; class Maker { private: int a; public: Maker() { cout << "无参构造函数" << endl; a = 20; } //拷贝构造函数 Maker(const Make 阅读全文
posted @ 2022-09-12 10:48 CodeMagicianT 阅读(30) 评论(0) 推荐(0)
摘要: 1.函数重载是:允许函数名相同,这种现象叫函数重载 2.函数重载的作用:是为了方便使用函数名 3.函数重载的条件:同一个作用域,参数的个数不同,参数的顺序不同,参数的类型不同 //参数的个数不同 void func() { cout << "func()" << endl; } void func( 阅读全文
posted @ 2022-09-12 10:41 CodeMagicianT 阅读(117) 评论(0) 推荐(0)
摘要: 当且仅当没有定义任何构造函数时,编译器才会提供默认构造函数。为类定义了构造函数后,程序员就必须为它提供默认构造函数。如果提供了非默认构造函数(如Stock(const char *co, int n, double pr)),但没有提供默认构造函数,但没有提供默认构造函数,则下面的声明将出错: St 阅读全文
posted @ 2022-09-12 10:35 CodeMagicianT 阅读(42) 评论(0) 推荐(0)