添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
鼻子大的人字拖  ·  How to Prevent Out of ...·  2 月前    · 
闷骚的树叶  ·  How Fast is .NET ...·  2 月前    · 
另类的路灯  ·  Array.prototype.splice ...·  1 月前    · 
快乐的卤蛋  ·  Array.prototype.slice( ...·  1 周前    · 
耍酷的移动电源  ·  Springboot ...·  9 月前    · 
完美的鸵鸟  ·  数据库MySQL之show ...·  1 年前    · 

编译器报错, 网上找了一圈, 大概明白: C++就是如此设定的 , 数组不能直接赋值, 可以使用 std::copy() , 或手工循环赋值, 但是就是不可以直接把一个数组赋值给另外一个数组.
但是 std::array std::vector 是可以的.

#include<iostream>
#include<array>
int main()
    std::array<int, 5> a = {1,2,3,4,5};
    std::array<int, 5> b = a;
    b[0] = 100;
    for(auto x:a) {std::cout << x << "\t";}
    std::cout << std::endl;
    for(auto x:b) {std::cout << x << "\t";}
1	2	3	4	5	
100	2	3	4	5	[Finished in 0.2s]