Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inherit member variable using proxy #117

Closed
MQN-80 opened this issue Jun 11, 2024 · 3 comments
Closed

inherit member variable using proxy #117

MQN-80 opened this issue Jun 11, 2024 · 3 comments
Labels
question Further information is requested

Comments

@MQN-80
Copy link

MQN-80 commented Jun 11, 2024

How do I inherit member variable if I have a Drawable class with two variable width and height, then Rectangle and circle want to inherit it

@mingxwa mingxwa added the question Further information is requested label Jun 12, 2024
@mingxwa
Copy link
Collaborator

mingxwa commented Jun 12, 2024

proxy only supports functions. It is not designed to support fields or nested types.

@mingxwa mingxwa closed this as completed Jun 12, 2024
@MQN-80
Copy link
Author

MQN-80 commented Jun 14, 2024

proxy only supports functions. It is not designed to support fields or nested types.

if I want to use base class's variable,so i still need to inherit the base class ?

@mingxwa
Copy link
Collaborator

mingxwa commented Jun 18, 2024

Assuming you are using proxy 2.4.0, you can define a member function (like .size()) or free function (like std::size()) to retrieve a field of a type, and wrap the functions with PRO_DEF_MEMBER_DISPATCH or PRO_DEF_FREE_DISPATCH, and define a facade with the dispatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants