上一页 1 2 3 4 5 6 ··· 8 下一页
摘要: if/else/elsifa = 'hello'b = falseif a p aelsif b p belse p 'ok'endunlessunless相当于if的反向断言unless false 'ok'end# => 'ok'if/unlessa = 1 if a != 1 #如果a不是1 则a复制为1b = 2 unless defined?(b) #如果b未定义... 阅读全文
posted @ 2018-02-16 23:52 罗道义 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Method(Function)def hi(name) p "hi " + nameendhi('666') # => "hi 666"hi 'code' #括号省略 => "hi code"def hello name p "hello #{name}"endhello 'world' # => "hello world"Method 参数def hi name='code' ... 阅读全文
posted @ 2018-02-16 23:37 罗道义 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 整数类型: 3,222小数: 3.14字符串: hello,world布尔类型: true(TrueClass),false(FalseClass)数组: [1,2],["hello","hello world"]Hash(字典): {"name"=>"luo","age"=>24},{:name=>"daoyi",:age=>24}Symbol(符号)::a,:hello,:"hello w... 阅读全文
posted @ 2018-02-16 21:54 罗道义 阅读(452) 评论(0) 推荐(0) 编辑
摘要: 继承子类从父类继承成员变量子类从父类继承成员函数#include "stdafx.h"class Person{public: int Age; int Sex; void Word() { printf("Person:Work"); }};class Teacher:public Person{public: int Level;};int m... 阅读全文
posted @ 2018-02-16 14:44 罗道义 阅读(428) 评论(0) 推荐(0) 编辑
摘要: 多态的实现原理#include "stdafx.h"#include #include class A{public: int x; virtual void Test() { printf("A \n"); }protected:private:};class B:public A{public: int x; void Test() { ... 阅读全文
posted @ 2018-02-16 14:43 罗道义 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 我们可以在什么地方创建对象?全局变量区 cPerson p;栈cvoid Max(){ Person p;}堆 new 和 deletec//在堆中创建对象: Person* p = new Person();//释放对象占用的内存 delete p;### 在堆中创建对象: new delete在C语言中我们使用malloc申请堆空间使用完毕后使用free释放空间C++:cla... 阅读全文
posted @ 2018-01-31 01:42 罗道义 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 好的编程习惯 -定义和实现分开代码会有更好的可读性但不是必须的在头文件中只留下声明代码Test.hstruct sclass{ int x; int y; int Bigger(int x,int y); int Max(int x,int y,int z);};Test.cppint sclass::Bigger(int x,int y){ if(x>y) {... 阅读全文
posted @ 2018-01-30 22:35 罗道义 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 什么是继承struct Person { int age; int sex; };struct Teacher { int age; int sex; int level; int classId; };struct Teacher:Person { int level; int classId; };总结: 1、什么是继承? 继... 阅读全文
posted @ 2018-01-29 21:41 罗道义 阅读(325) 评论(0) 推荐(0) 编辑
摘要: int x = 123; //补码int float f = 123.4F; //IEEE编码int i = 'A'; //神马情况???我们在代码中写入int i = 'A';反编译后汇编就编程了mov dword ptr ss:[esp-4],0x41为什么会变成41呢?字符类型ASCII 表(American Standard Code for... 阅读全文
posted @ 2018-01-29 20:42 罗道义 阅读(418) 评论(0) 推荐(0) 编辑
摘要: 寄存器传参和堆栈传参寄存器传参MOV ECX,1MOV EBX,2CALL XXMOV EAX,ECXADD EAX,EBXRETN堆栈传参 --ESP寻址PUSH 1PUSH 2CALL XXXMOV EAX,DWORD PTR SS:[ESP+8] //当内存中括号中包含ESP或者EBP的话 用SSADD EAX,DWORD PTR SS:[ESP+4]RETN 8堆栈传参 --EBP寻址P... 阅读全文
posted @ 2017-09-20 10:15 罗道义 阅读(390) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 8 下一页
本站总访问量