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

How to add MPC as a member in a class? #210

Closed
C1009919253 opened this issue Mar 7, 2022 · 2 comments
Closed

How to add MPC as a member in a class? #210

C1009919253 opened this issue Mar 7, 2022 · 2 comments

Comments

@C1009919253
Copy link

For example, I want to add MPC's object mpc_t in class A, but I can't initialize mpc_t in A's constructor function.
How could I fix that problem?

@condor-cp
Copy link

I would guess the problem here is the lack of a default constructor of the MPC class.

What you can do to fix that is for example have a shared_ptr as your member class and dynamically define it in the constructor.
Another option can be to call the MPC constructor in the initializer list as suggested in https://stackoverflow.com/questions/12328150/class-member-without-a-default-constructor

@C1009919253
Copy link
Author

I would guess the problem here is the lack of a default constructor of the MPC class.

What you can do to fix that is for example have a shared_ptr as your member class and dynamically define it in the constructor. Another option can be to call the MPC constructor in the initializer list as suggested in https://stackoverflow.com/questions/12328150/class-member-without-a-default-constructor

Thanks for your help, I tested the first way, and it worked!

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

No branches or pull requests

2 participants