luodaoyi's Blog

能用就行

精通ASM/C/C++/RUST/C#/Java/JavaScript/Python/Golang/ruby 的Hello World 编写。

luodaoyisince 2014 208 篇文章

Cpp9 模板

模板 下面是一个针对int的冒泡排序 // _20180301.cpp : Defines the entry point for the console application. // #include "stdafx.h" void Sort(int* arr,int nLength) { int i,k; for (i = 0;ix > base.x …

Cpp8 运算符重载和深浅拷贝

深浅拷贝 相同类型间可以直接拷贝 // _20180212.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include class A { private: int* a; public: A() { a = new …

Ruby11 拾遗

Agenda Loop Expression File Read/Write Debug Process & Thread Loop while a = 10 while a > 0 puts a a -= 1 end until a = 100 until a == 0 puts a a -= 1 end loop a = 10 loop do break …

Ruby10 Class Module Gem 深入

Agenda class_eval & instance_eval method_missing Module as a namespace Gems require vs load $LOAD_PATH class_eval 首先class_eval是只有类才能调用的,Class#class_eval class_eval会重新打开当前类的作用域 # …

Ruby9 Class & Modules 进阶

Ruby的内部类结构 Array.class # => Class Class.class # => Class superclass 查看父类 Array.superclass # =>Object Object.superclass # =>BasicObject BasicObject.superclass # => nil ancestors 查看当 …

Ruby8 继承(Inheritance)和模块(Modules)

继承示例 # inheritance class User attr_accessor :name, :age def initialize name, age @name, @age = name, age end def panels # ||= 操作符, 如果变量不存在 那么就赋值 @panels ||= ["Profile", "Products"] …

Ruby7 OOP

Everything is Object 一切皆对象 1 2 3 4 5 6 7 a = "hello" a.class # => String b = 3.14 b.class # => Float c = %w[pear cat horse] c.class # => Array Instance Method & Instance Attribute …

Ruby6 细节补充

代码规范 使用UTF-8编码 使用空格缩进,不使用tab, 1 tab = 2 spaces 不需要使用分号(;)和反斜杠()连接代码 Demo # basic types a = 1 b = "hello world" # one line c = ["pear", "cat", "dog"] # or multiple lines c2 = [ …

Ruby5 其他的奇技淫巧

变量赋值 # 变量交换 a = 1 b = 2 b,a = a,b puts a puts b puts "-" * 30 x = [1, 2, 3] a, b = x #默认会把数组中的值依次赋值给 a ,b puts a puts b puts "-" * 30 x = [1, 2, 3] a, *b = x #这里a会接受第一个元素 b用了*号 表示接 …

Ruby4 Blocks and Exceptions

Block 代码块 Block是一个参数 匿名参数 Callback 使用do/en或者{}来定义 {puts "hello"} Demo: # block usage def hello puts "hello method start" yield yield puts "hello method end" end hello {puts "i am …

Ruby3 流程控制

if/else/elsif 1 2 3 4 5 6 7 8 9 a = "hello" b = false if a p a elsif b p b else p "ok" end unless unless相当于if的反向断言 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 …

Ruby1 数据类型,变量

整数类型: 3,222 小数: 3.14 字符串: hello,world 布尔类型: true(TrueClass),false(FalseClass) 数组: [1,2],["hello","hello world"] Hash(字典): {"name"=>"luo","age"=>24},{:name=>"daoyi",:age=>24} …

Ruby2 Method and Block

Method(Function) 1 2 3 4 5 6 7 8 9 def hi(name) p "hi " + name end hi("666") # => "hi 666" hi "code" #括号省略 => "hi code" def hello name p "hello #{name}" end hello "world" # => …

Cpp7 C++的多态实现 — 虚表

多态的实现原理 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 …

Cpp6 封装、继承和多态

继承 子类从父类继承成员变量 子类从父类继承成员函数 #include "stdafx.h" class Person { public: int Age; int Sex; void Word() { printf("Person:Work"); } }; class Teacher:public Person { public: int Level; …

kali rolling 国内源

#阿里云kali源 deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib deb …

Cpp5 在堆中创建对象和引用类型

我们可以在什么地方创建对象? 全局变量区 Person p; 栈 void Max() { Person p; } 堆 new 和 delete //在堆中创建对象: Person* p = new Person(); //释放对象占用的内存 delete p; 在堆中创建对象: new``delete 在C语言中我们使用malloc申请堆空间 使用完毕后使 …

Cpp4 类成员的访问控制

好的编程习惯 -定义和实现分开 代码会有更好的可读性 但不是必须的 在头文件中只留下声明代码 Test.h struct sclass { int x; int y; int Bigger(int x,int y); int Max(int x,int y,int z); }; Test.cpp int sclass::Bigger(int x,int y) …

Cpp3 继承

什么是继承 struct Person { int age; int sex; }; struct Teacher { int age; int sex; int level; int classId; }; struct Teacher:Person { int level; int classId; }; 总结: 1、什么是继承? 继承就是数据的复制 …

Cpp2 构造函数和析构函数

什么是构造函数 #include "stdafx.h" #include struct Sclass { int a; int b; int c; int d; Sclass()//构造函数 { printf("观察这个函数 \n"); } Sclass(int a,int b,int c,int d)//构造函数 { this->a=a; …