Discussion Overview
The discussion revolves around creating an array of pointers to objects in C++ without using virtual functions. Participants explore various approaches to manage pointers from derived classes A_1 and A_2 within a new class, Array_Class, while adhering to specific constraints set by an assignment.
Discussion Character
- Homework-related
- Debate/contested
- Technical explanation
Main Points Raised
- One participant describes the requirement to create a class Array_Class that holds two arrays of pointers, one for each derived class A_1 and A_2, and seeks advice on how to implement this without virtual functions.
- Another participant suggests that the proposed method of using a type variable and a switch statement is poor programming practice and recommends using a single array of pointers to the base class A, leveraging polymorphism instead.
- A later reply emphasizes that the assignment constraints prohibit the use of virtual functions and casting, which limits the design options available.
- One participant proposes using function overloading in Array_Class to handle pointers to A_1 and A_2 separately, suggesting this as a potential solution to the problem.
- Another participant expresses agreement that overloading may be a suitable approach to meet the assignment requirements.
Areas of Agreement / Disagreement
Participants express disagreement on the appropriateness of certain programming practices, with some advocating for a more polymorphic approach while others are constrained by the assignment's rules. There is no consensus on a definitive solution, as the discussion reflects varying opinions on how to best address the problem within the given constraints.
Contextual Notes
The discussion is limited by the specific requirement to avoid virtual functions and casting, which constrains the design options available to participants. The effectiveness of proposed solutions may depend on interpretations of the assignment's guidelines.