5.1 Consider the class class base { public: virtual void iam() cout << “base\n"; }; a. Derive two classes from class base, and for each define iam() to write out the name of the class. b. Declare objects of each class, and call iam() from them. c. Assign the address of objects of the derived classes to base pointers and call iam() through the pointers. d. Remove the virtual keyword from the base class member function, run your code again, and compare the results.
Q: Question 3 (a) Provide a single line of C++ code that will declare an integer pointer variable named…
A: a. Write a C++ code that will declare an integer pointer variable give it label/name x b. We have…
Q: Q: consider a class network of fig(1). The class result derives information from three branch…
A:
Q: write a c++ oop program from the following 4 subjects (chose at least 4 from them) the subjects are…
A: #include <iostream>#include <vector>#include <fstream> using namespace std; //…
Q: 7. Consider implementing a function to dynamically allocate an array of integers and set all its…
A: An array in terms of programming is a collection of variables(elements) that share the same type of…
Q: 6. Consider the following JavaScript skeletal program: // The main program var x; function sub1() {…
A: In the given code two var x are declared. One var x is declared in the main and the second var x is…
Q: Indicate whether or not the following is true: When it comes to dynamically bound virtual functions,…
A: Introduction: A strong binding occurs when a pointer or reference is associated with a member's work…
Q: write c++ to solve the following problem 2 Make a class whose objects each represent a bag of…
A: #include<iostream> using namespace std; class bag { private : int weight;…
Q: (1) Implement the class A- Write a C++ program to define a class QuadraticEquation described as…
A: Algorithm: Start Define class QuadraticEquation with private members a,b,c Define get and set…
Q: Write a C++ class to define a point (x, y). The class should have the following: a. Two private…
A: private variables cannot be accessed outside the class So, use getX(), getY() methods to access…
Q: Write a C++ program to check for the not-eligible donor by throwing a custom exception. Strictly…
A: The answer is
Q: 6. Suppose we have two classes, one of which extends the other: class Base (...); class Derived:…
A: Since variable b is declared as a Base* type The static type of variable b after line 4 has been…
Q: using C++ 0OP Q1: Consider a class network of fig(1). The class Result derives information from two…
A: Your C++ program is given below as you required with an output.
Q: (a) Can we pass default arguments to overloaded functions? Support your answer. (b) Does C++…
A: (a).Can we pass default arguments to overloaded functions? Yes, we can pass default arguments to…
Q: Write an OOP complete program in class overloading constructor, destructor and pointers by using…
A: Oops(object oriented programming) is a programming paradigm which uses the concept of classes and…
Q: Q: consider a class network of fig(1). The class result derives information from three branch…
A: Approach: In this code, there is used concept of friend function. To create function as friend of…
Q: What is Pure Virtual Functions? By using Pure Virtual Functions, create a simple “shape” hierarchy:…
A: Pure virtual function: A pure virtual function is the member function of the base(Parent) class and…
Q: Write a C++ program which perform the following: 1. Create a Class MinMax 2. Create two Private…
A: Below is the required C++ program: -
Q: 4:Complete the following statement to make it logically true: If a certain class C2 is a derived…
A: Given, Three classes C1, C2, C3 where C2 is a derived class of C3 using private access specifier C2…
Q: 2.5) write a function called SwapPointers() in order to interchange pointers(pp)and qq so that arter…
A: Input : Given two-pointers: pp and qq. Output : Swap two-pointers contents.
Q: 13.5 LAB: Zip code and population (class templates) Define a class StatePair with two template types…
A: Code is written below in c++ language- Main.cpp #include<iostream>#include…
Q: Justify the following statements with suitable example: 1) constructor for a virtual base class is…
A: Given : Justify the following statements with suitable example: 1) constructor for a virtual base…
Q: I need answer of three questions 1.Three of the following expressions have the same value. Which of…
A: 1) Assume A variable that is located at memory location 0xf55 and it contains 46 and assume that ptr…
Q: (1) Implement the class A- Write a C++ program to define a class QuadraticEquation described as…
A: Given, write a c++ program fro Quadratic Equation
Q: Justify the following statement with the help of a suitable example: “In a class hierarchy of…
A: A virtual function is a member function which is declared within a base class and is re-defined or…
Q: 9.15 Consider the following declaration in C: double(*foo (double (*)(double, double []), double))…
A: According to the asked question, the solution is given below with a proper explanation.
Q: write a c++ oop program from the following 4 subjects (chose at least 4 from them) the subjects are…
A: Step 1:- This program contains the following topics:- 1.vector 2.Inheritance 3.Operator Overloading…
Q: create a simple “shape” hierarchy in C++: a base class called Shape and derived classes called…
A: Virtual Function is a member function of the base class which is overridden in the derived class.…
Q: Consider the class class base public: virtual void iam) cout <« "base\n"; ): Derive two classes from…
A: #include<iostream.h>#include<conio.h>#include<stdio.h> using namespace std; class…
Q: 8.2 Implement a class Quiz that implements the Measurable interface. A quiz has a score and a letter…
A: Solution :: You can run this code here and see.. https://www.onlinegdb.com/online_java_compiler…
Q: 1.Write A Program To Define A Class “ Library ” Which May Have Data About I) Area In Square Feet, I
A: A square is a flat shape identified by four points at each of its four corners in one plane. A…
Q: Question 2 Choose the correct answer after considering the following statements: 1. A weak pointer…
A: The correct answer considered of the given statement
Q: Justify the following statement with the help of a suitable example: “In a class hierarchy of…
A: Given: Justify the following statement with the help of a suitable example:“In a class hierarchy of…
Q: By using pure virtual functions, create a simple “shape” hierarchy in C++: a base class called Shape…
A: Introduction of the Virtual Function: A virtual function is the member function of the base(Parent)…
Q: write a c++ oop program from the following 4 subjects (chose at least 4 from them) the subjects are…
A: I made four classes to explain at least four of the following oop subject: OOP subjects explained…
Q: 13.5 LAB: Zip code and population (class templates) Define a class StatePair with two template…
A: C++ code: main.cpp #include<iostream>#include <fstream>#include <vector>#include…
Q: 13.5 LAB: Zip code and population (class templates) Define a class StatePair with two template types…
A: Note: TODO code is highlighted bold in StatePair.h and StatePairMain.cpp files. Sample data…
Q: Draw the memory allocation structure(s) for this instruction including the content values if…
A:
Q: 5. Consider the following high-level code snippet. Assume that the base addresses of array1 and…
A: Each array contains 100 integers. So we reserve memory for 100*4=400 bytes
Q: When is the reference count of an object managed by a shared pointer decreased by 1?
A: Option: When a shared pointer's copy constructor is invoked or when a shared pointer is assigned…
Q: Ql: Consider a class network of fig(1). The class Result derives information from two branch, find:…
A: Note :- You have not mention the language of the program so, i'm answering your question in C++…
Q: 3.40 Implement function partition() that splits a list of soccer players into two groups. More…
A: This is your solution code
Q: use c++ to Implement a city database using a BST to store the database records. Each database record…
A: Actually, given information: c++ to Implement a city database using a BST to store the database…
Q: Consider the following class declarations in C++: class C { protected: int x; public: void f(){...};…
A: the class hierarchy
Q: (a) Can we give overloaded functions default arguments? Back up your claim. (b) Is stringent type…
A: overloaded function : C++ allows specification of more than one function of the same name in the…
Q: 3- Write a program to implement a class "student" with the following members. Name of the student.…
A: As per the requirement program is developed. Note: In the question programming language is not…
Q: Please explain in detail Scott Meyers’s point: Use weak_ptr for shared_ptr like pointers that can…
A: We need to explain Scott Meyers’s point: Use weak_ptr for shared_ptr like pointers that can dangle.…
Step by step
Solved in 2 steps with 2 images
- [2/25, 05:28] Vishal Singh Rawat: Kindly store employee details using class with python program [2/25, 05:28] Vishal Singh Rawat: There are 4 employees Details of all employee: Name: John , Designation: Manager , Salary: 80000 Name: Mike , Designation: Team Leader , Salary: 50000 Name: Derek , Designation: Programmer , Salary: 30000 Designation: Assistant , Salary: 25000 Name: RajBy using pure virtual functions, create a simple “shape” hierarchy in C++: a base class called Shape and derived classes called Circle, Square, and Triangle. In the base class, make a virtual function called draw( ), and override this in the derived classes. Make a pointer of Shape and objects of derived class and call draw( ) through the base-class pointers, to verify the behavior of the virtual function.Justify the following statements with suitable example: 1) constructor for a virtual base class is invoked before any non virtual base class 2) a virtual function can be declared as a friend of another class
- Create a simple “Car” hierarchy in C++: a base class called Car and derived classes called Toyota, Honda, and Mazda. In the base class, make a virtual function called start( ), and override this in the derived classes. Make a pointer of Car and objects of derived class and call start( ) through the base-class pointers, to verify the behavior of the virtual function.Create a class named Line: (a) Define private data members p1 and p2 as pointer to Point objects (the one we had in lectures), slope and length as double variables. (b) Define setter and getter functions. (c) Define a null-constructor that initializes numeric variables with zero and allocate dynamic memory for points and initialize them to [0,0] as well. (d) Overload a constructor that allocates memory for points, initilize them with given arguments, and calculate the slope and length. (e) Implement destructor, copy constructor and copy assignment operator. (f) Create a function called ”parallel” that takes too Line objects, returns true when given lines are parallel and returns false otherwise. (g) Overload the less than (<) and greater than (>) and equality (==) operators (compare the length). (h) Write a functions that reads lines in the format provided in the lines.txt from the file (without any change) and stores them in a vector named Lines. (i) Sort the objects of Lines…Need code in C++. I have answer till part 7,please go through the code and correct it if you find any mistakes. If not answer the last 4 parts(8,9,10,11) Create a class called Line with the followings:1. Private members: p1 and p2 as pointer to Point objects (code provided below), slope and length as double variables2. Define setter and getter functions.3. Define a default constructor that allocate dynamic memory for points andset everything to 0.4. Overload a constructor that allocates memory for points, initilize themwith given arguments, and calculate the slope and length.5. Overload a destructor, a copy constructor and a copy assignment operator.6. Create a function called ”parallel” that return true when given lines areparallel and returns false otherwise7. Overload the less than (<) and greater than (>) and equality (==) oper-ators (compare the length)8. Write a functions that reads lines in the format provided in the lines.txtfrom the file and stores them in a vector named…
- 6.3.25 Develop a pair of TOY functions that implement a pushdown stack, passing the values to push and pop in R[B] and the address of the stack in R[A]. This question was taken from Computer science an interdisciplinary approach. NOTE: I don't need an answer with java or high-level language code but the TOY code as described in the book which has a specific set of opcodes in hexadecimal for eg 18AB; means that adding results of R[A] and R[B] and store them in R[8]. and so on...Write a C++ program : Make a class for rectangle which calculates perimeter and area by doing the following: use the dynamic allocation. has a default constructor has a destructor.. Write a program to create a base class: “Question3”, with protected data member: x(int) and with pure virtual function: “Task ()” [Returns no value and takes no argument].Create a derived class of “Question3” such as “Sub1” (Derive features in public mode).In sub1, there is a member function in public section: get_data1 () to take input for x,and define Task () in this class to display the factorial of x. [Implement the aboveprogram by creating pointer to base in main () function and call the necessaryfunctions].in c++ program
- Justify the following statement with the help of a suitable example:“In a class hierarchy of several levels of several levels, if we want a function atany level to be called through a base class pointer then the function must bedeclared as virtual in the base class”.Write a program to create a base class: Question3, with protected data member: x (int) and with pure virtual function: Task () [Returns no value and takes no argument]. Create a derived class of Question3 such as Sub1 (Derive features in public mode). In sub1, there is a member function in public section: get_data1 () to take input for x, and define Task () in this class to display the reverse of x. [Implement the above program by creating pointer to base in main () function and call the necessary functions].4) Answer the question in C++ A) What is wrong with the following code segment? enum CarType {GM, FORD, BMW}; int main() { CartType = BMW; return 0; } B) Assume that the addresses of x and y is 0x61feb8 and 0x61feb0, respectively. What will be the values of x, y, p, and q, respectively, when the following code runs successfully? int main() { int x; double y; int* p = &x; double* q = &y; *p = 3; *q = 3.14; increaseByOne(p, q); cout << x << " " << y << endl; cout << p << " " << q << endl; return 0; }void increaseByOne(int*& p1, double* q1){ (*p1)++; (*q1)++; p1++; q1++;} The four value: