EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 1, Problem 15E
Explanation of Solution
Declaration “derivedClass” follows “genClass”:
- Declaration of “derivedClass” class follows “genClass”.
- The “genClass” would act as base class and “derivedClass” acts as subclass.
- A base class is declared so that its member data instances could be shared with any of other inclusions of same base in further derived classes.
- The technique used is termed as virtual inheritance.
- The functions in base class could be used by derived classes.
Refer question 15 from chapter 1 for given declarations.
Member function invocation:
- The function “process1()” in “derived Class” contains integer parameters, the function declaration is hidden in “genClass”...
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Object-Oriented Programming
Create a Java program that has the following:
Inheritance - Create a superclass and one or more subclasses that inherit properties and methods from the superclass.
Polymorphism - Show polymorphism by using method overriding and method overloading.
Provide an example of runtime polymorphism by creating objects of the subclasses and calling overridden methods.
Encapsulation - Demonstrate the concept of encapsulation by applying access modifiers (private, protected, public) appropriately in your program.
Abstraction - Utilize abstract classes and methods in your program to illustrate abstraction.
Show examples of the following words: super, this, static, final
(NO USE OF AI)
Consider the following class code segment:
class aNewClass {
public: …….
private:
string name;
int *q;
int length;
};
// constructor
aNewClass::aNewClass() {
q = new int[10]; // dynamic data
….
}
Name at least ONE thing you should add/code for the dynamic data in this class. (HINT: Look at the member variables).
Question 9
Which XXX will avoid a memory leak?
class MyClass {
public:
MyClass();
int value;
private: int* ptr;
};
MyClass::MyClass () {
ptr = new int;
*ptr = 0;
delete ptr;
}
int main() {
int value = 100;
int *ptr1= new int;
//XXX
ptr1 = &value;
O delete value
O delete MyClass
O delete ptr1
O delete ptr
Chapter 1 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Knowledge Booster
Similar questions
- What are the advantages of utilizing interfaces as opposed to abstract classes?arrow_forwardJava- Suppose you write a new constructor for an extended class. Describe two different ways that the superclass's instance variables could be initialized within the constructor for the extended class.arrow_forwardTrue or false?(a) Every object is an instance of the object class.(b) If a class does not extend a superclass explicitly, it extends object by default.arrow_forward
- If Class A inherits from Class B, we say that Class B is the subclass and Class A is the superclass. True Falsearrow_forwardlanguage: Java Class Inheritance with an abstract class Define a class Employee with the following fields: _name, _empId, _department, _position (_title), _yearlySalary, _fullTime (a boolean: true/false) , _month , _year (time of hire) Add constructor and properties Define an abstract method GetBiMonthlySalary() (if the employee is paid twice a month) Define an abstract method GetVacationTime() that returns the number of vacation time this employee would have based on time of hire Override the ToString() method to return a string that contains the information pertaining to an employee such as name, empId, department, and where full time or not. Define a class HourlyEmployee that inherits from Employee. This class should have 2 fields of its own: _hours (hours worked in half a month) and _wage (hourly wage) Provide necessary constructor, properties and methods Override the ToString() to also return the additional fields Gets 3 days of vacation after first year if the…arrow_forwardJava Programming Object-Oriented Programming In an abstract class, write a factory method for creating a category of object of your choice (aside from furniture). Also, write the class representing that category.b) Write the child classes that are necessary to create 3 different types of objects that belong to that categoryarrow_forward
- Use JAVA - This task helps you understand how constructors work in inheritance Create a superclass, called SuperClass. Create a constructor for it. Inside the constructor, let it print “this is super class.” Create a childclass of SuperClass, called ChildClass. Create a constructor for it. Inside the constructor, let it print “this is child class.” Create a main function and create a new object for ChildClass. Observe what’s printed in console. What will happen if you have a default constructor without parameters in addition to the one with parameters?arrow_forward- Simple factory is not considered a design pattern because it does not decouple the client from concrete classes Select one: True False 2- structural patterns provide guidance on the way in which classes interact to distribute responsibility Select one: True False 3- The Simple factory is used when you want to limit the instantiation of classes to one implementation Select one: True False 4- When a class A is composing a reference to another class B, then we say that class A has-a class B relationship Select one: True Falsearrow_forwardTopic: C# Write the C# program with explaining the proper logic used and screenshot of the output which you got in Visual Studio... Difference between static and Instance class in C# Create some classes which implement the concept of method overloading and overriding. Read on difference between Abstract class and Interfaces and find out the example when to use what? Create classes with example of Abstract class and Interface.arrow_forward
- In Java a class is allowed to inherit from as many superclasses as needed. True Falsearrow_forwardDescribe one advantage of requiring a class to implement an interface.arrow_forwardDetermine if this statement is true or false Take the following method, which is defined in some class: class SomeClass: SomeBaseClass{ private int override MyMethod() { //do something.... } } This is an example of run time polymorphism, as MyMethod is being redefined in the child class by the override keyword.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT