指向成员成员的指针

编程入门 行业动态 更新时间:2024-10-25 18:22:59
本文介绍了指向成员成员的指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

说我有两节课: A级 { 公开: int x; }; class B { public: A a; }; 然后我如何构建一个指向B :: ax的成员指针?什么是语法 呢? 谢谢!

Say I have two classes: class A { public: int x; }; class B { public: A a; }; Then how do I construct a member pointer to B::a.x ? What''s the syntax for it? Thanks!

推荐答案

hu ***** @ gmail 写道: Say我有两节课: A级 { public: int x; }; B级 { 公开: A; }; 然后如何构造一个指向B :: ax的成员指针?什么是语法 呢? Say I have two classes: class A { public: int x; }; class B { public: A a; }; Then how do I construct a member pointer to B::a.x ? What''s the syntax for it?

为什么你认为你需要它?这有用吗: B b; int * ptr =& bax; V - 请在通过电子邮件回复时删除资金''A' 我不回复热门回复,请不要问

Why do you think you need it? Does this help: B b; int *ptr = &b.a.x; V -- Please remove capital ''A''s when replying by e-mail I do not respond to top-posted replies, please don''t ask

hu ***** @ gmail 写道: 说我有两节课: A级 { 公开: int x; }; B级 { public: A a; }; 那怎么办我构造了一个指向B :: ax的成员指针?什么是语法 呢? 谢谢! Say I have two classes: class A { public: int x; }; class B { public: A a; }; Then how do I construct a member pointer to B::a.x ? What''s the syntax for it? Thanks!

不确定您需要什么,但下面的代码示例可能有所帮助 int A :: * ptr = A :: x; 例子; 示例。* ptr = 15; JB

Not sure what you require, but the code sample below may be of help int A::*ptr = A::x; A Example; Example.*ptr = 15; JB

n2xssvv.g02gfr12930写道: n2xssvv.g02gfr12930 wrote: hu **** *@gmail 写道: >说我有两个班级: A班级 { 公开: int x; }; B班 {公开: A a; }; 然后如何构造一个指向B :: ax的成员指针?它的语法是什么?谢谢! >Say I have two classes:class A{public: int x;};class B{public: A a;};Then how do I construct a member pointer to B::a.x ? What''s the syntaxfor it?Thanks!

不确定您需要什么,但下面的代码示例可能有所帮助 int A :: * ptr =斧头;

Not sure what you require, but the code sample below may be of help int A::*ptr = A::x;

int A :: * ptr =& A :: x; (没有&符号''不合法的。

int A::*ptr = &A::x; (without the ampersand it''s not legal).

一个例子; 例子。* ptr = 15; A Example; Example.*ptr = 15;

现在为B做这个...... :-) V - 请在通过电子邮件回复时删除资金''A' 我没有回复最热门的回复,请不要''请问

Now do that for a ''B''... :-) V -- Please remove capital ''A''s when replying by e-mail I do not respond to top-posted replies, please don''t ask

更多推荐

指向成员成员的指针

本文发布于:2023-07-28 02:43:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1226563.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:成员   指针

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!