Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对 C++ 相当陌生,想知道是否允许我执行以下操作:
class oFoo{ ... } class Foo{ int x; oFoo* oArray[x]; public: Foo(int xVal); Foo~(); }
我可以使用 x 作为指向类 oFoo 的指针数组的界限吗?
不,只允许编译时常量。如果您需要动态数组,请查看std::vector。