c++) explain your answer. Suppose Data is a programmer-defined data type.
You want to overload the << operator and allow cascaded function calls. Which of the following is the best function header? explain your answer.
a. ostream operator<<( ostream &output, const Data &dataToPrint )
b. ostream operator<<( const Data &dataToPrint, ostream &output )
c. ostream& operator<<( const Data &dataToPrint, ostream &output )
d. ostream& operator<<( ostream &output, const Data &dataToPrint )
d. ostream& operator<<( ostream &output, const Data &dataToPrint )

Reason: -------- 1. stream operators must be passed and returned by reference. in option d we are returning and passing ostream& to operator<< function 2. dataToPrint must be passed as const, because << operator is not supposed to print it. in option d we are passing dataToPrint as const Data &
c++) explain your answer. Suppose Data is a programmer-defined data type. You want to overload the...
QUESTION 18 According to class materials, the program is allowed to overload operators only if at least one incoming parameter received by the operator has a class type. 1. (a) True 2. (b) False QUESTION 19 According to the course materials, a function can take value parameters and reference parameters. A value parameter is a separate variable from the one in main() or another calling function only if the function value parameter has a different name than the one in...
C++
(5 pts in total) Step 1: Operator Overload (3pts) Let's revisit your lab 5. Make an operator overload function for comparing shapes based on their area. For example, you want to have the ability to compare two shapes using the > and < operators, such as if ($1 > s2). In order to do this, you need to make an operator overload for > and < bool operator>(const Shape &, const Shape &); bool operator<(const Shape &, const Shape...
Please answer all the questions thank you
1) (Classes – 20 Points) Consider the following class declaration for Time to complete the questions below: DO NOT WRITE MORE THAN ASKED FOR. class Time private: int hours; int minutes; public: Time(); Time (int , int m = 0); void addMin(int m); void addHr(int h); void reset(int h = 0, int m = 0); Time operator+(const Time & t) const; Time operator-(const Time & t) const; Time operator*(double n) const; friend Time...
NEED ASAP PLEASE HELP
Task:
---------------------------------------------------------------------------------------------------------------------------------
Tasks to complete:
----------------------------------------------------------------------------------------------------------------------------------------
given code:
-----------------------------------------------------------------------------------------------------------------------------------------------
main.cpp
#include <iostream>
#include <iomanip>
#include "fractionType.h"
using namespace std;
int main()
{
fractionType num1(5, 6);
fractionType num2;
fractionType num3;
cout << fixed;
cout << showpoint;
cout << setprecision(2);
cout << "Num1 = " << num1 << endl;
cout << "Num2 = " << num2 << endl;
cout << "Enter the fraction in the form a / b: ";
cin >> num2;
cout << endl;
cout <<...
C++ NEED AS SOON AS POSSIBLE! BigInt class is used for the mathematical operations that involve very big integer calculations that are outside the limit of all available primitive data types. For example, factorial of 100 contains 158 digits in it so we can’t store it in any primitive data type available. We can store as large Integer as we want in it. Your goal is to overload the operators for a generic “BigInt” class. You will need to write...
Task The task for this assignment is to have the following user-defined data type: struct rgb { unsigned char red; unsigned char green; unsigned char blue; }; be able to be: read in from a stream (e.g., std::cin), i.e., write: std::istream& operator >>(std::istream& is, rgb& colour); (see below) written out to a stream (e.g., std::cout), i.e., write: std::ostream& operator <<(std::ostream& os, rgb const& colour); (see below) stored in a container, e.g., std::vector<rgb>, std::array<rgb,16>; (see below) processed via algorithms (and other...
solve it in c++10 Create a composition between the classes Job and Salary. Class Salary a. data member: 1. money b. constructors: 1. default constructor 2. user defined constructor with a parameter to set money c. standard accessor and mutator functions Class Job a. data members: title (name of the job) salary (object of type Salary) b. constructors: 1. default constructor 2. user defined constructor to set title and salary 3. implement constructor delegation c. standard accessor and mutator function...
Objectives You will implement and test a class called MyString. Each MyString object keeps track of a sequence of characters, similar to the standard C++ string class but with fewer operations. The objectives of this programming assignment are as follows. Ensure that you can write a class that uses dynamic memory to store a sequence whose length is unspecified. (Keep in mind that if you were actually writing a program that needs a string, you would use the C++ standard...
C++ assignment help! The instructions are below, i included the main driver, i just need help with calling the functions in the main function This assignment will access your skills using C++ strings and dynamic arrays. After completing this assignment you will be able to do the following: (1) allocate memory dynamically, (2) implement a default constructor, (3) insert and remove an item from an unsorted dynamic array of strings, (4) use the string class member functions, (5) implement a...
Data Structures and Algorithm Analysis – Cop 3530 Module 3 – Programming Assignment This assignment will access your skills using C++ strings and dynamic arrays. After completing this assignment you will be able to do the following: (1) allocate memory dynamically, (2) implement a default constructor, (3) insert and remove an item from an unsorted dynamic array of strings, (4) use the string class member functions, (5) implement a copy constructor, (6) overload the assignment operator, (7) overload the insertion...