是否可以将std::array<class T, std::size_t N>
用作类的私有属性但在类的构造函数中初始化其大小?
class Router{
std::array<Port,???> ports; //I dont know how much ports do will this have
public:
Switch(int numberOfPortsOnRouter){
ports=std::array<Port,numberOfPortsOnRouter> ports; //now I know it has "numberOfPortsOnRouter" ports, but howto tell the "ports" variable?
}
}
我可能会使用一个指针,但是没有它可以做到吗?