give_me_a_name是什么意思?
what does the give_me_a_name mean?
我是 c++ 的新手,我在 clion 中编写了以下代码:
Student student[] = {
Student("Larry", 95.5, "This is Larry", 1);
Student("Paul", 78.0, "This is Paul", 2);
Student("Tom", 80.0, "This is Tom", 3);
};
它暗示了一个叮叮当当的整洁:object destroyed immediately after the creation; did you mean to name the object?
如果我遵循它,代码将更改为:
Student student[] = {
Student("Larry", 95.5, "This is Larry", 1);
Student give_me_a_name("Paul", 78.0, "This is Paul", 2);
Student("Tom", 80.0, "This is Tom", 3);
};
那么give_me_a_name
是什么意思呢?为什么会有这样的语法?
这正是它听起来的样子。你使用了分号而不是逗号,这让 Clang 认为你正在构造一个对象,并立即丢弃它,就好像你自己Student("Paul", 78.0, "This is Paul", 2);
一样。因此,它建议您通过为其命名来将构造的对象存储在变量中。Clang 不知道你想要什么名字,所以它会在那里放置一个占位符名称供您替换。
相关文章:
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 标准 N3337 5.2.10 第 7 条中的C++"类型"是什么意思?
- "类模板示例<int>;"语句对 C++11 是什么意思?
- 线应该是什么意思
- "CID"在AT+HTTPPARA= "CID" ,1中是什么意思
- 表达式"b=(b-x)&x"是什么意思?
- 这个表达是什么意思?
- 此代码验证公式是什么意思?
- 跟踪日志中的T.11803()是什么意思?
- 这个额外的关键字在这个 c++ 类声明中是什么意思?
- * 和 ** 在 C++ 函数声明中是什么意思?
- _T("xyz")是什么意思?
- #define Dbg(fmt,..) (0) 是什么意思? 警告:表达式无效
- 这行代码到底是什么意思?
- 当我们说在执行程序时将操作系统的控制权传递给main()函数时,我们的意思是什么
- 这句话在c++中的意思是什么
- 这个typedef的意思是什么
- 这句话的意思是什么
- 意思是什么
- 这个句法的意思是什么?