[英]Where is the pointer pointing?
This is the defination for my class.这是我的 class 的定义。
class RingBuffer {
private:
static const size_t buffer_size;
public:
std::shared_ptr<RingBufferLock> ring1_;
std::shared_ptr<RingBufferLock> ring2_;
RingBuffer();
};
I take a pointer out of the class object:我从 class object 中取出一个指针:
std::shared_ptr<RingBuffer> rings = std::make_shared<RingBuffer>();
Do the value of rings.get()
function call is the same as the value of rings_->ring1_.get()
function call? rings.get()
function call 的值是否与rings_->ring1_.get()
function call 的值相同?
rings.get()
: rings.get()
:
This is getting raw pointer from rings
which gives you RingBuffer *
这是从
rings
中获取原始指针,它为您提供RingBuffer *
rings_->ring1_.get()
: rings_->ring1_.get()
:
I suppose you mean rings->ring1_.get()
, which first dereferences rings
and then get raw pointer from member ring1_
.我想你的意思是
rings->ring1_.get()
,它首先取消引用rings
然后从成员ring1_
获取原始指针。 It is the same with rings.get()->ring1_.get()
.与
rings.get()->ring1_.get()
相同。 The final result is a RingBufferLock *
最后的结果是一个
RingBufferLock *
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.