subject

C++ Consider the definition of the class dateType below:
a. Write the statement that includes a friend function named before in the
class dateType that takes as parameters two objects of type dateType
and returns true if the date represented by the first object comes before the
date represented by the second object; otherwise, the function returns false.
b. Write the definition of the function you defined in part a.

class dateType

{

public:

void setDate(int, int, int);

void setMonth(int);

void setDay(int);

void setYear(int);

void print() const;

int numberOfDaysPassed();

int numberOfDaysLeft();

void incrementDate(int nDays);

int getMonth() const;

int getDay() const;

int getYear() const;

int getDaysInMonth();

bool isLeapYear();

dateType(int month, int day, int year);

dateType();

private:

int dMonth;

int dDay;

int dYear;

};

a. In a class, why do you include the function that overloads the stream insertion operator, <<, as a friend function?

b. In a class, why do you include the function that overloads the stream extraction operator, >>, as a friend function?

If you define your own exception class, what is typically included in that class?

Suppose the exception class myException is defined as follows:
class myException
{
public:
myException()
{
message = "myException thrown!";
cout << "Immediate attention required!"
<< endl;
}
myException(string msg)
{
message = msg;
cout << "Attention required!" << endl;
}
string what()
{
return message;
}
private:
string message;
}
Suppose that in a user program, the catch block has the following form:
catch (myException mE)
{
cout << mE. what() << endl;
}
What output will be produced if the exception is thrown with the default constructor?
Also, what output will be produced if the exception is thrown with the
constructor with parameters with the following actual parameter?
"May Day, May Day"

Name three exception-handling techniques.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 21:00
Analyze the following code. int x = 1; while (0 < x) & & (x < 100) system.out.println(x++); a. the loop runs forever. b. the code does not compile because the loop body is not in the braces. c. the code does not compile because (0 < x) & & (x < 100) is not enclosed in a pair of parentheses. d. the numbers 1 to 99 are displayed. e. the numbers 2 to 100 are displayed.
Answers: 3
question
Computers and Technology, 22.06.2019 22:30
Which of the following factors would your hypothetical supervisor look at when deciding whether to test a biological material sample for dna? the amount of other evidence you have implicating a suspect in a crime the annual budget for the crime lab both of the above none of the above; you would almost always order a test
Answers: 3
question
Computers and Technology, 23.06.2019 17:00
In which of the following ways can using test-taking tips you? a. you can focus on the information that you need to study. b. you will see the answers to the test. c. you will study more. d. you will be less organized.
Answers: 1
question
Computers and Technology, 23.06.2019 19:40
Use a physical stopwatch to record the length of time it takes to run the program. calculate the difference obtained by calls to the method system.currenttimemillis() just before the start of the algorithm and just after the end of the algorithm. calculate the difference obtained by calls to the method system.currenttimemillis() at the start of the program and at the end of the program so that the elapsed time includes the display of the result. use the value returned by the method system.currenttimemillis() just after the end of the algorithm as the elapsed time.
Answers: 3
You know the right answer?
C++ Consider the definition of the class dateType below:
a. Write the statement that includes...
Questions
question
English, 16.09.2020 14:01
question
English, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
History, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01
question
Mathematics, 16.09.2020 14:01