如何读取这个C ++语句 [英] How do read this C++ statement
本文介绍了如何读取这个C ++语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在通过Prata的C ++底漆Plus,并遇到关于* this指针的这个声明:
I'm currently going through C++ primer Plus by Prata and came across this statement regarding *this pointer:
const Stock &topval(const Stock &s) const;
授予股票是一个类和topval函数,
Giving that Stock is a class and topval a function ,
您如何阅读这个语句?
我尝试使用顺时针/螺旋方法, 。
我相信,了解如何阅读它将允许我更好地理解它试图证明的概念。
I tried using the clockwise/spiral approach but I get confused by all the const. I believe that understand how to read it will allow me to better understand the concept that it is trying to prove.
谢谢!
推荐答案
topval( ) // topval is a member function...
const; // In which *this is const...
const Stock &s // Taking in a reference
// to a const Stock...
const Stock & // And returning a reference
// to a const Stock.
这篇关于如何读取这个C ++语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文