Question
C++ Create a class named LineSeg and write the code for the .h and .cpp files (credit pts shown alongside) 1. Provide 2 private data
C++
Create a class named LineSeg and write the code for the .h and .cpp files (credit pts shown alongside)
1. Provide 2 private data members of type Point named m_pta and m_ptb for the class LineSeg. (2)
2. Provide a single constructor for the class LineSeg that takes 2 Point objects by const reference which are then used to initialize m_pta and m_ptb private data members mentioned above. (2)
3. Provide a destructor for the class LineSeg. (1)
4. Provide accessor (i.e. get.) and mutator (i.e. set) functions (4)
5. Show how you would prevent clients of the LineSeg class from using its copy constructor. (1)
6. Show how you would prevent clients of the LineSeg class from using its default constructor. (1)
7. Create a main function in which you
Create 4 points p1, p2, p3, p4 with any arbitrary x, y co-ordinates of your choice. (1)
Create a LineSeg object named lss using the 2 point objects p1 and p2 you created above by invoking the LineSeg class constructor in the local stack space. (1)
Create a LineSeg object pointer name plsh which you then use to heap allocate a single LineSeg object in the using the 2 point objects p3, p4 and an appropriate C++ operator. (2)
Show how to call the get methods on the lss and plsh objects to print out the x, y co-ordinates of endpoints of the 2 LineSeg objects. (3)
Show how you will return heap allocated memory back to the runtime before exiting function main. (2)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started