我在world.h中有班级世界:
#include "stdafx.h"
#include "World.h"
static Ground* ground = new Ground(10, 10);
在函数的另一个类中,我尝试使用静态变量:
location
并且在world.cpp中我有:
public location: any;
ngOnInit() {
let autocomplete = new google.maps.places.Autocomplete((this.search.nativeElement), {types: ['(cities)']});
//add event listener to google autocomplete and capture address input
google.maps.event.addListener(autocomplete, 'place_changed', function () {
let place = autocomplete.getPlace();
});
}
但我收到以下错误:
答案 0 :(得分:2)
static Ground* ground = new Ground(10, 10);
你在那里缺少World::
,所以你要定义一个完全不相关的变量,它恰好具有相同的名称。你应该这样:
Ground* World::ground = new Ground(10, 10);