上一页 1 ··· 6 7 8 9 10 11 12 13 下一页
摘要: class TableTennisPlayer{ private: string firstname; string lastname; bool hasTable; publc: TableTennisPlayer(const string & fn="none",const string & l 阅读全文
posted @ 2024-08-09 15:13 zhongta 阅读(21) 评论(0) 推荐(0)
摘要: C++提供的特殊成员函数 1.你未定义构造函数会生成默认构造函数 2.你未定义析构函数会生成默认析构函数 3.未定义拷贝构造函数时生成拷贝构造函数 4.赋值运算符= 5.&取地址运算符 拷贝构造函数使用 1.使用赋值运算符时= 2.进行值传递时,进行值传递意味会产生一份传递参数的拷贝。 3.产生临时 阅读全文
posted @ 2024-08-05 14:13 zhongta 阅读(25) 评论(0) 推荐(0)
摘要: Time类为例 class Time{ private: int hours; int minutes; Time operator +(const Time &t)const; Time operator -(const Time &t) const; Time operator *(double 阅读全文
posted @ 2024-08-02 15:07 zhongta 阅读(22) 评论(0) 推荐(0)
摘要: 1.常函数 const Stock land=Stock("Kludgehorn");//常对象 void show() const;//常函数声明 void Stock::show() const;//常函数实现 2.对象产生前定义常量 class Bakery{ private: const i 阅读全文
posted @ 2024-08-01 16:25 zhongta 阅读(15) 评论(0) 推荐(0)
摘要: namespace Jill{ double bucket(double n){...} double fetch; struct Hill{..}; } char fetch;//全局作用域 int main(){ using namespace Jill;//包含Jill作用域 Hill Thr 阅读全文
posted @ 2024-07-28 13:54 zhongta 阅读(21) 评论(0) 推荐(0)
摘要: // CPPTest.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include<fstream> #include <iostream> #include<string> #include<cstring> #include<cmath> using name 阅读全文
posted @ 2024-07-26 15:15 zhongta 阅读(33) 评论(0) 推荐(0)
摘要: int global =100;//外部链接,所有文件皆可访问。 static int one_file=50;//内部链接,static关键字,单文件可以使用 void function2(){ static int count=0;//无连接,函数内部使用。静态变量。 } //上述三种变量作用时 阅读全文
posted @ 2024-07-26 14:46 zhongta 阅读(21) 评论(0) 推荐(0)
摘要: int x; decltype(x) y; decltype(x+y) xpy;//make xpy the same type as x+y; xpy=x+y; 1.表达式类型不含括号 double x=5.5; double y=7.9; double &rx=x; const double * 阅读全文
posted @ 2024-07-25 14:30 zhongta 阅读(14) 评论(0) 推荐(0)
摘要: 1.如果只有一个函数匹配,则调用唯一的函数。 2.如果同时存在非函数模板函数和函数模板函数,优先调用非函数模板函数。 3.拥有多个函数模板函数,则由最佳匹配原则匹配最合适的函数。 4.如果最佳匹配出2个以上的函数,则报错。 阅读全文
posted @ 2024-07-25 14:14 zhongta 阅读(20) 评论(0) 推荐(0)
摘要: 1.函数重载区分const 和非const 参数 void drivel(const char *bites);//1 void dribble(char *bits);//2 void dribble(const char * cbits);//3 const char p1[20]="hello 阅读全文
posted @ 2024-07-23 15:03 zhongta 阅读(8) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 下一页