package main import ( "fmt" ) type person struct { age int name string } func (p person)testPer() { fmt.Println("person::testPer()") } // 注意两者区别 //type man person 另外类型 type man = person // 别名 func (m man) getAge() int { return m.age }…
operator 关键字 operator 关键字用来重载内置运算符,或提供类/结构声明中的用户定义转换.它可以定义不同类型之间采用何种转化方式和转化的结果. operator用于定义类型转化时可采用2种方式,隐式转换(implicit)和显示转换(explicit) public class OperatorTestDemo { public static void Test() { OperatorTest mc = 1;//通过隐式装换,生成myclass对象 Console.WriteL…
一.type / create or repalce type 区别联系 相同: 可用关键字create type 或者直接用type定义自定义类型, 区别: create type 变量 as table of 类型 -- create type 变量 as object( 字段1 类型1, 字段2 类型2 ); -------------------------- type 变量 is table of 类型 -- type 变量 is record( 字段1 类型1, 字段2 类型2 );…