cost 625 ms
从const对象访问非const方法

[英]Accessing non const method from const object

我有一个C ++示例,我尝试在通过const getter访问的类成员上设置属性。 我希望这会给我d1->property().set_val(2);一个错误d1->property().set_val(2); 因为property()方法是const ,应该给我一个没有s ...

将字符串文字传递给期望字符串的 function

[英]Passing string literal to function which expect string

让我们假设我有一个 function 期望参数是一个字符串(非常量)。 但正如我们所知,字符串文字本质上是 const 。 有什么方法可以将字符串文字传递给期望非常量的 function。 我知道这会导致错误,因为文字本质上是 const,但 function 期待非 const。 任何方式来铸造 ...

如何继承父常量并访问它们?

[英]How to inherit parent constants and access them?

如何从父 class 访问 const 变量? 我有一个 PI 常量,我想在 TCylinder class 中使用它,如何访问它? 我知道我可以使用 Math.PI,但对于未来我想知道 } ...

将 const* 存储在 const 向量中

[英]Storing const* in const vector

我必须处理的相关接口代码包含两个函数,一个是检索对象,另一个是我必须将对象作为向量提交。 问题是,检索 function 返回const Object* ,但提交 function 需要const vector<Object*> 。 我知道这可以用const_cast<Object ...

错误:将 'const std::__cxx11::list<>' 作为 'this' 参数传递会丢弃限定符

[英]error: passing ‘const std::__cxx11::list<>’ as ‘this’ argument discards qualifiers

我有一个小问题,找不到解决方法。。 在 my.hpp 文件中,我声明了这两个函数和结构,但收到错误“将 'const std::__cxx11::list&lt;&gt;' 作为 'this' 参数丢弃限定符。” 我试图做的 in.cpp 文件: 我怎样才能使这项工作? ...

2019-10-19 09:58:05   1   39    c++ / const  
是否可以将.reduce 与 const 一起使用?

[英]Is it possible to use .reduce with a const?

我正在完成我的编码训练营中的一项作业。 他们要求我们使用.reduce 来得出一个值。 但是,他们使用 const 变量初始化了总值。 当我尝试使用 const 值解决这个问题时,它一直在抛出错误。 因为在我看来,你不能改变 const 值。 我只是用 let 替换了 const。 我不确定我是否 ...

有没有办法声明将使用 constexpr 在源文件中定义的公共 static const (有什么区别)?

[英]Is there a way to declare a public static const that will be defined in the source file using constexpr (and what difference is there)?

在我的 header 中,我声明了一个公共 static 常量,并在源文件中将其定义为 class 成员。 我想在源文件中定义它,因为我包含并使用它的常量,并且我不想包含在我的 header 中。 如果我在 header 中使用 static constexpr 它需要在那里定义。 header ...

如何在其他脚本中使用变量值作为变量名?

[英]How can i use variable value as variable name in other script?

我有一个带有配置文件的统一项目(用于动画名称) 在另一个脚本中,我想使用激活 animation 我的问题是将name_Of_The_Anim_I_Want_To_Activate.ToString()转换为实际的 animation 名称我可以使用哪个工具将name_Of_The_Anim_I_ ...

初始化不变字节片的最佳方法

[英]Best way to init an unchanging byte slice

在 Go 中,您可以按如下方式初始化字节切片(在 Go Playground 上尝试)package main import ( "fmt" "encoding/hex" ) // doStuff will be called many times in actual appli ...

修改 const 变量值的最简单方法

[英]Easiest way to modify a const variable's value

对于我的 CS class 我有一个变量const int m_vin ,在我的代码中我需要编辑这个值。 我的印象是无法编辑const变量。 我将如何 go 关于这个? 编辑:这里是m_vin的说明,它是名为 Vehicle 的 Object 的成员变量:m_vin,一个 const int,表示唯 ...

2019-10-09 17:53:26   6   78    c++ / const  
更改 c++ 中 static const int 的值

[英]Change value of static const int in c++

我需要更改static const int成员的值。 我知道这有点奇怪,但我需要它来克服我正在使用的框架给出的限制! 我已经尝试过了,但它不起作用,它会出现一个错误,说“未定义对 MyClass::staticConstMember 的引用”: ...

你应该如何创建一个 std::experimental::observer_ptr 到一个不能改变它指向的值的非常量 object ?

[英]How should you create a std::experimental::observer_ptr to a non-const object that cannot mutate the value it points to?

这是将std::experimental::observer_ptr创建到不能改变它指向的值的非const object 的规范方法吗?auto i = int{0}; auto p = std::experimental::make_observer(&amp;std::as_const(i) ...

'const DList 的无效转换<int> * const' 到 'DList<int> *' [-fpermissive] 返回 object 时</int></int>

[英]invalid conversion from 'const DList<int>* const' to 'DList<int>*' [-fpermissive] when returning an object

这是我的任务和链表的代码,我的任务是实现链表的迭代器类,我刚刚实现了开始和结束函数,当我运行测试器检查这些函数是否工作时,我得到了错误在返回 const_iterator object 时,在这些行下面出现“从 'const DList* const' 到 'DList*' [-fpermissi ...

全局常量还需要用常量表达式初始化吗?

[英]Do global constants still have to be initialized with constant expressions?

由于 GLSL 4.20 const限定的变量不再需要由常量表达式初始化。 但是当我真正尝试定义一个由非常量表达式初始化的全局const限定变量时,Mesa 会发出错误。 这是示例代码: 这是我测试编译的方式(以避免任何 OpenGL 代码):$ glsl_compiler --version 4 ...

我可以在 C 中将 char* 传递给 const char* 吗?

[英]Can I pass char* to const char* in C?

我正在实现一个 function 将字符串转换为 C 中的双精度。 function 没有破坏性,即我不修改传递的字符串,我只是在 function 中读取它。 我想将 char*、const char* 以及字符串文字传递给 function。 以下 function 是否适合此目的? 我认为 ...

2019-10-02 08:42:13   2   92    c / char / const  
如何从键 const - JavaScript 开始编写 function?

[英]How do I write a function starting with the keywork const - JavaScript?

我希望你一切都好。 我对编码很陌生,我正在尝试完成一个挑战,我必须创建一个 function 和 output 以控制台: 我没有得到的部分是简报要求我以关键字“const”(然后是 const 名称)开头。 我写了以下输出所需的内容,但我不确定这是否正确。 简报中要求我编写一个带有两个参数(国家 ...


 
粤ICP备18138465号  © 2020-2023 STACKOOM.COM