Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(c) You are given a class Line. You need to define a new class DashedLine that inherits from Line and additionally has two attributes int

image text in transcribed

(c) You are given a class Line. You need to define a new class DashedLine that inherits from Line and additionally has two attributes int *dashes and int *gaps. i. Write the C++ declaration for DashedLine that clearly shows the inher- itance from Line. Make sure that you explicitly declare the default con- structor, correctly set access modifiers, and follow information hiding pol- icy with respect to the variables int *dashes and int *gaps so that all set/get methods are introduced. [7 marks] ii. In the previous part, assume that Line has a float variable weight defined as a part of the class. What is the access modifier that must be used with weight if we want it to be available to DashedLine but not to other classes that have not inherited Line? [2 marks]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions