【问题标题】:Getting this error plz help !!! <built-in>: note: previous declaration 'namespace std { }', I am getting this error at std[5]得到这个错误请帮助!!! <built-in>: 注意:之前的声明 \'namespace std { }\',我在 std[5] 收到这个错误
【发布时间】:2022-12-23 22:09:49
【问题描述】:
struct student
{
    string std_id;
    string f_name;
    string l_name;
    string father_name;
    string cnic;
    string cgpa;
}std[5];

Here is the error message

我发现了这种声明结构变量的方法,但是 Visual Studio Code 给了我错误,有人告诉我这个东西可以在现代编译器、IDE、文本编辑器等中使用,但它在 vscode 中不起作用,谁能告诉我如何解决这个问题?

【问题讨论】:

  • 不要将变量命名为std
  • 在 C++ 中 std 已经被使用/保留,所以选择一个更好的名字
  • 你为什么将文字作为图像发布?

标签: c++ structure variable-declaration


【解决方案1】:

std 是 C++ 中的保留关键字

您需要使用其他名称

【讨论】:

  • 虽然使用了std,但它不是关键字。 Read this。它是一个命名空间。
猜你喜欢
  • 2014-11-11
  • 1970-01-01
  • 2016-12-28
  • 1970-01-01
  • 2022-10-17
  • 2018-06-14
  • 1970-01-01
  • 2014-05-09
  • 2022-10-07
相关资源
最近更新 更多