gpt4 book ai didi

C++ 在对象的对象内调用成员函数

转载 作者:行者123 更新时间:2023-11-30 00:37:32 26 4
gpt4 key购买 nike

我有一个 C++ 类,简而言之,它有一个如下所示的声明:

class Pico {
...
Document document; // Custom Document class
...
}

稍后我调用了 Document 类的公共(public)成员函数之一:

this->document->enableEditing();

但是,IntelliSense 会在 this 下划线并指出“表达式必须具有指针类型”。我该怎么做才能解决这个问题?

最佳答案

你想要

this->document.enableEditing();

Document 成员不是指针,因此您需要 . 代替 ->

关于C++ 在对象的对象内调用成员函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13130451/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com