I have a method called initializeObjects() in my main.cpp file, and I want to call it from a method in another source file, named Scene.cpp. How do I do that? This is my main.cpp file, without the headers:
static void initializeObjects();
int main() {
Scene myScene;
myScene.render(640,480);
return 0;
}
void initializeObjects(){
//Add a plane of gray color
Scene::shapes.push_back(std::make_shared<Plane>(Vector3D(0,1,1), Vector3D(0,0,80), COLOR_GRAY));
//Add two spheres
Scene::shapes.push_back(std::make_shared<Sphere>(100.0, Vector3D(0,50,0), COLOR_WHITE));
Scene::shapes.push_back(std::make_shared<Sphere>(60.0,ORIGIN, COLOR_RED));
}
static, you explicitly tell the compiler that it should not be accessible in any other source file. So if you want it thus accessible, dropstatic.