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.
我想创建一个不在堆上而是在堆栈上的数组。我的数组的大小将基于文件中的行数。
我发现了这个 SO 帖子:
为什么可变长度数组不是 C++ 标准的一部分?
是否仍然没有办法在堆栈上创建一个数组,其中大小由其他东西决定,除了一个 const 吗?
不,除非在编译时知道它的大小,否则您不能在堆栈上创建数组。不仅是const,而且是编译时常量。
const
我想使用位移运算符将一个数字乘以 10。 为了尝试,我初始化了x = 1. 然后我分配x = x<<1 + x<<3.This 打印x = 32。 但是当我分配时x = (x<<1
x = 1
x = x<<1 + x<<3
x = 32
x = (x<<1