使用方法返回指针内容 [英] returning a pointers content with a method

查看:95
本文介绍了使用方法返回指针内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

So i have class that holds inside a pointer to an object i want to use an acessor to retrive the value for example:

class Example{
private:
Pointing* aPointer;

public:
Example(Pointing* point){
aPointer = point;
}

int acessor(){
return aPointer->exampleMethod();
}


};


when compiling i receive an error anyone have any ideas

推荐答案

你需要告诉我们错误是什么。我们无法读懂你的想法。然后,你的访问者(原文如此)应首先检查指针是否为空。但是,所有这些都应该编译。我不明白为什么这不会编译,除非Pointer没有'exampleMethod'。
You need to tell us what the error is. We can't read your mind. Then, your acessor (sic) should check first if the pointer is null. But, all of that should compile. I can't see why this would not compile, unless Pointer does not have an 'exampleMethod'.


这篇关于使用方法返回指针内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆