应用
- 04教育的基本逻辑
- 05人际交往的基本逻辑
- 06AI时代如何定义价值
封面01 / 04
书籍
爱的闭环
楚栋浩
书籍
爱的
闭环
人生的意义
如何活着
如何社交
如何有效设计
什么是爱
活着的目的
要不要结婚
要不要生育
教育的基本逻辑
人际交往的基本逻辑
AI时代如何定义价值
C++ 是一门非常优秀的编程语言,但有很多历史包袱、学习路径陡峭
可读性>简单>简洁
基本类型、复合类型(指针、引用、函数指针)、变量定义、函数定义、逻辑语句、结构体定义、继承、多态、RAII、函数重载、运算符重载、命名空间等,最新进展见 项目仓库
var width i32 := 6;
var height := 7i32;func Add(foo i32, bar i32) i32 {
foo + bar
}func Abs(value i32) i32 {
if value < 0 {
-value
} else {
value
}
}
func SumEven(limit i32) i32 {
var sum := 0i32;
var value := 1i32;
while value <= limit {
if value % 2 == 0 {
sum += value;
}
value++;
}
sum
}// 基类
struct Shape {
virtual {
func Area(this © Shape) i32;
}
}
ctor Shape() {}
dtor Shape() {}
func Area(this © Shape) i32 { 0 }
// 派生类与重写
struct Rectangle : Shape {
virtual {
override func Area(this © Rectangle) i32;
}
width i32;
height i32;
}
ctor Rectangle(width i32, height i32) {
this.Shape := Shape();
this.width := width;
this.height := height;
}
dtor Rectangle() {}
func Area(this © Rectangle) i32 {
this.width * this.height
}
struct Square : Shape {
virtual {
override func Area(this © Square) i32;
}
side i32;
}
ctor Square(side i32) {
this.Shape := Shape();
this.side := side;
}
dtor Square() {}
func Area(this © Square) i32 {
this.side * this.side
}
// 多态调用
func GetArea(shape © Shape) i32 {
shape.Area()
}
func Example() i32 {
var rectangle := Rectangle(6, 7);
var square := Square(5);
GetArea(rectangle) + GetArea(square)
}C++ 是一门非常优秀的编程语言,但有很多历史包袱、学习路径陡峭
可读性>简单>简洁
基本类型、复合类型(指针、引用、函数指针)、变量定义、函数定义、逻辑语句、结构体定义、继承、多态、RAII、函数重载、运算符重载、命名空间等,最新进展见 项目仓库
var width i32 := 6;
var height := 7i32;func Add(foo i32, bar i32) i32 {
foo + bar
}func Abs(value i32) i32 {
if value < 0 {
-value
} else {
value
}
}
func SumEven(limit i32) i32 {
var sum := 0i32;
var value := 1i32;
while value <= limit {
if value % 2 == 0 {
sum += value;
}
value++;
}
sum
}// 基类
struct Shape {
virtual {
func Area(this © Shape) i32;
}
}
ctor Shape() {}
dtor Shape() {}
func Area(this © Shape) i32 { 0 }
// 派生类与重写
struct Rectangle : Shape {
virtual {
override func Area(this © Rectangle) i32;
}
width i32;
height i32;
}
ctor Rectangle(width i32, height i32) {
this.Shape := Shape();
this.width := width;
this.height := height;
}
dtor Rectangle() {}
func Area(this © Rectangle) i32 {
this.width * this.height
}
struct Square : Shape {
virtual {
override func Area(this © Square) i32;
}
side i32;
}
ctor Square(side i32) {
this.Shape := Shape();
this.side := side;
}
dtor Square() {}
func Area(this © Square) i32 {
this.side * this.side
}
// 多态调用
func GetArea(shape © Shape) i32 {
shape.Area()
}
func Example() i32 {
var rectangle := Rectangle(6, 7);
var square := Square(5);
GetArea(rectangle) + GetArea(square)
}