diff options
Diffstat (limited to 'Examples/go/extend/runme.go')
-rw-r--r-- | Examples/go/extend/runme.go | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go index 770e27802..a56968937 100644 --- a/Examples/go/extend/runme.go +++ b/Examples/go/extend/runme.go @@ -7,19 +7,12 @@ import ( "fmt" ) -type CEO struct{} - -func (p *CEO) GetPosition() string { - return "CEO" -} - func main() { // Create an instance of CEO, a class derived from the Go // proxy of the underlying C++ class. The calls to getName() // and getPosition() are standard, the call to getTitle() uses // the director wrappers to call CEO.getPosition(). - - e := NewDirectorManager(new(CEO), "Alice") + e := NewCEO("Alice") fmt.Println(e.GetName(), " is a ", e.GetPosition()) fmt.Println("Just call her \"", e.GetTitle(), "\"") fmt.Println("----------------------") @@ -27,7 +20,6 @@ func main() { // Create a new EmployeeList instance. This class does not // have a C++ director wrapper, but can be used freely with // other classes that do. - list := NewEmployeeList() // EmployeeList owns its items, so we must surrender ownership @@ -49,15 +41,13 @@ func main() { // CEO, but now Go thinks the object is an instance of class // Employee. So the call passes through the Employee proxy // class and on to the C wrappers and C++ director, eventually - // ending up back at the Java CEO implementation of + // ending up back at the Go CEO implementation of // getPosition(). The call to GetTitle() for item 3 runs the // C++ Employee::getTitle() method, which in turn calls // GetPosition(). This virtual method call passes down - // through the C++ director class to the Java implementation + // through the C++ director class to the Go implementation // in CEO. All this routing takes place transparently. - fmt.Println("(position, title) for items 0-3:") - fmt.Println(" ", list.Get_item(0).GetPosition(), ", \"", list.Get_item(0).GetTitle(), "\"") fmt.Println(" ", list.Get_item(1).GetPosition(), ", \"", list.Get_item(1).GetTitle(), "\"") fmt.Println(" ", list.Get_item(2).GetPosition(), ", \"", list.Get_item(2).GetTitle(), "\"") @@ -66,11 +56,11 @@ func main() { // Time to delete the EmployeeList, which will delete all the // Employee* items it contains. The last item is our CEO, - // which gets destroyed as well. + // which gets destroyed as well and hence there is no need to + // call DeleteCEO. DeleteEmployeeList(list) fmt.Println("----------------------") // All done. - fmt.Println("Go exit") } |