Say I have the class signatures
Class1(Class2 c);
Class2(Class1 c);
How do I initialize both?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For one of the classes, you don’t provide the reference in the constructor, but you can use a
set-method instead. Initializing them both dependent on each other when none of them previously exists seems difficult.Also note that there might be better solutions to this. Such as using an Observer-pattern, it all depends on how you plan on using your objects.