Google の Go プログラミング言語の構造体の中にベクトル変数を入れようとしています。これは私がこれまでに持っているものです:
欲しい:
type Point struct { x, y int }
type myStruct struct {
myVectorInsideStruct vector;
}
func main(){
myMyStruct := myStruct{vector.New(0)};
myPoint := Point{2,3};
myMyStruct.myVectorInsideStruct.Push(myPoint);
}
もつ:
type Point struct { x, y int }
func main(){
myVector := vector.New(0);
myPoint := Point{2,3};
myVector.Push(myPoint);
}
ベクトルをメイン関数で問題なく動作させることができますが、使いやすいように構造体内にカプセル化したいと考えています。