我正在做一个限制订单系统,作为我的计算机科学课程的一个项目,我想知道在我的order类中使用静态向量来包含我所有的订单是不是最好的实践,或者我应该在我的主程序中使用它?我仍然在解决所有的问题,但基本上哪一个更好,或者有没有另一种我应该探索的方法:
class Order {
public:
static vector<Order> orders; //should this be private instead?
}
int main(){
vector<Order> orders; //should I just pass this to my methods?
让我用下面的简短代码来介绍这个问题:
function SomeObject() {
// Personaly I call this part initialization...
this.anything = "anything";
// ... but here somebody call function init...
this.init();
}
// ... which is declared there...
SomeObject.prototype.init = function () {
// ... and contains more initial