上一页 1 ··· 216 217 218 219 220 221 222 223 224 ··· 259 下一页
摘要: static this() 和static ~this(),模块构造和析构函数,每线程一次,总程序一次的,可用shared static this() 和 shared static ~this() 一堆模块叫一个包. import std.stdio; 选择导入:import std.stdio 阅读全文
posted @ 2020-03-01 10:55 zjh6 阅读(26) 评论(0) 推荐(0)
摘要: class LifetimeObserved { int[] array; static size_t counter;//静态成员 this() { array.length = 30_000; ++counter; }//结构好像没有(). ~this() { --counter; } } im 阅读全文
posted @ 2020-03-01 10:53 zjh6 阅读(19) 评论(0) 推荐(0)
摘要: interface SoundEmitter { // ... } interface SoundEmitter { string emitSound(); //仅声明 } interface I { int func(int i) in { } out { //可用进出来保证 } } class 阅读全文
posted @ 2020-03-01 10:52 zjh6 阅读(25) 评论(0) 推荐(0)
摘要: 每个类自带toString opEquals opCmp toHash函数.因为继承自对象类. 定义他们,需要盖.因为有hash,所以可以成为关联数组的键. TypeInfo提供类型的信息.每个类型一个.typeid可以访问相关信息.ti可用来比较是否相同,访问特殊函数,决定两个类型是否相同其经常关 阅读全文
posted @ 2020-03-01 10:51 zjh6 阅读(21) 评论(0) 推荐(0)
摘要: class SubClass : SuperClass { // ... } class Clock { int hour; int minute; int second; void adjust(int hour, int minute, int second = 0) { this.hour = 阅读全文
posted @ 2020-03-01 10:49 zjh6 阅读(17) 评论(0) 推荐(0)
摘要: 类, oop:封装,继承,多态.类是引用类型.未初化时为空针,初化后变成实体.实际类必须由新构造. 而引用与无效比较是错误的,所以不能这样.必须用is比较. MyClass referencesAnObject = new MyClass; assert(referencesAnObject !is 阅读全文
posted @ 2020-03-01 10:46 zjh6 阅读(42) 评论(0) 推荐(0)
摘要: 对类,不能重载opAssign,因为类是按引用的.赋值是引用. 重载运算符,主要是为了方便书写. struct TimeOfDay { // ... ref TimeOfDay opOpAssign(string op)(in Duration duration)//(1) if (op == "+ 阅读全文
posted @ 2020-03-01 10:42 zjh6 阅读(27) 评论(0) 推荐(0)
摘要: 名字意思__MODULE__模块名__FILE__源文件名__FILE_FULL_PATH__源文件完整路径__LINE__行号__FUNCTION__函数名__PRETTY_FUNCTION__美化函数名__DATE__编译日期__TIME__编译时间__TIMESTAMP__时间戳__VENDO 阅读全文
posted @ 2020-03-01 10:40 zjh6 阅读(18) 评论(0) 推荐(0)
摘要: 结构是值类型,直接复制.可有默认值.如果未初化,则成员自动用该类型的默认值. struct TimeOfDay { int hour; int minute; } //定义 auto periodStart = TimeOfDay(8, 30); auto periodDuration = Time 阅读全文
posted @ 2020-03-01 10:29 zjh6 阅读(20) 评论(0) 推荐(0)
摘要: 两种类型不同,当然不能一起操作,会出现编译错误. 从到boolintbyteintubyteintshortintushortintcharintwcharintdcharuint 类型提升,从低到高.没问题,不会出现截断. int a = 0; int b = 1; size_t c = 0; w 阅读全文
posted @ 2020-03-01 10:28 zjh6 阅读(24) 评论(0) 推荐(0)
上一页 1 ··· 216 217 218 219 220 221 222 223 224 ··· 259 下一页