C++指针上的关键字运算符"this"
C++ keyword operator on "this" pointer
努力理解我在开源代码中遇到的这种语法:
/// cast *this into an gpstk::RinexNavData.
/// @throw if the record is invalid or not an ephemeris (isNav()==false)
operator RinexNavData() throw(gpstk::Exception);
/// cast *this into a gpstk::RinexObsData
/// @throw if the record is invalid or not an observation (isObs()==false)
operator RinexObsData() throw(gpstk::Exception);
如果我正确解释评论,它正在通过"此"指针更改对象的类型。但这似乎是通过操作员完成的吗?无法打入涉及关键字" this"的良好网络搜索。寻找有关"操作员"的使用方式的参考或解释。C 操作员的Web搜索不会导致我发现到目前为止的任何东西。
不要在此处思考this
的使用;*this
只是表示"当前对象",因此程序员正在使用速记来描述操作员的作用。
的确,像任何转换操作员一样,它采用当前对象,并为 convert 提供一种手段。
相关文章:
- 运算符++();调用和++(*this)有什么区别?
- 为什么在通过引用返回运算符分配时取消引用'this'指针?
- 如何在"this"上调用运算符()?
- 从 std::ostream 重载 << 运算符时,为什么编译器会给出"too many parameters for this operator function"错误?
- 当取消引用运算符 (*) 重载时,*this 的使用是否受到影响?
- C++指针上的关键字运算符"this"
- 假设我有作业运算符,我的复制构造函数是this = obj可以
- 为什么我的重载运算符+在向自身添加变量时会在返回时使"this"未初始化?
- "return *this"赋值运算符重载
- 是否可以在实例方法中使用带有"this"的重载运算符?
- 重载 = 运算符时如何使用 THIS 指针
- 运算符+=可以调用自己,但"*this"与"rhs"交换吗?
- 可能的分段错误:是否正确使用了"this->"运算符?
- 使用 This 关键字和运算符重载
- 在运算符中使用“this”
- 由 sf::P acket 定义的运算符<<是否与 sf::P acket 派生类的 (*this) 一起工作?
- 运算符this的c++重载
- c++重写运算符和this
- 我可以在运算符=中使用placement new(this)吗
- 重载类函数中的按位和 (&) 运算符和"*this"