先来一个返回指针的测试,结果跟想象一样 type A map[int]string type B struct { A c int } func main() { b := B{make(A), 10} NewB := func() *B { return &b } c := NewB() c.c = 100 c.A[1] = "3" fmt.Println(b, c) } /* output {map[1:3] 100} &{map[1:3] 100} */ 再试试直
分别以函数返回值方式和参数传引用方式测试了vector.map两种容器,代码如下: // testContainer.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <vector> #include <map> #include <chrono> using nam