C++ static factory constructor
问题 I am in the process of making a simulation and it requires the creation of multiple, rather similar models. My idea is to have a class called Model and use static factory methods to construct a model. For example; Model::createTriangle or Model::createFromFile . I took this idea from previous java code and was looking for ways to implement this in C++. Here is what I came up with so far: #include <iostream> class Object { int id; public: void print() { std::cout << id << std::endl; } static