Question 8: Questions 8 - 12 are based on the following code. Now, this code results in a compile error (where it's marked "here"). Why? class Fraction { private:   int numerator;   int denominator; public:   Fraction(int n, int d) {     numerator = n;     denominator = d;   }   void display() { cout << numerator << "/" << denominator << endl; } }; int main() {   Fraction f;  // <-- here   return 0; } Group of answer choices There is no constructor defined Copy constructor is undefined Default constructor is undefined Constructor is defined as public   Question 9:   Find an incorrect definition of getter/setter for Fraction. Group of answer choices void setNumerator(int n) { numerator = n; } void getNumerator() { return numerator; } void setDenominator(int d) { denominator = d; } int getDenominator() { return denominator; }   Question 10:   What would be the printout of the following code segment? Fraction f(2, 3);  f.display(); Group of answer choices 23 2 3 2,3 2/3   Question 11:   Suppose I added the following copy constructor to Fraction. Which statement will invoke this method? Fraction(const Fraction& b) {   denominator = b.denominator;   numerator = b.numerator; } Group of answer choices Fraction f(2, 3); Fraction g = f; Fraction h; Fraction* j = nullptr;   Question 12:   Suppose I added the following overloaded operator method to Fraction. Which statement will invoke this method? Fraction operator+(const Fraction& b) {     Fraction o;     o.denominator = denominator * b.denominator;      o.numerator = numerator * b.denominator + b.numerator * denominator;      return o; } Group of answer choices Fraction f(2, 3); Fraction g = f; Fraction h; Fraction h = f + g;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Question 8:

Questions 8 - 12 are based on the following code. Now, this code results in a compile error (where it's marked "here"). Why?

class Fraction {
private:
  int numerator;
  int denominator;
public:
  Fraction(int n, int d) {
    numerator = n;
    denominator = d;
  }
  void display() { cout << numerator << "/" << denominator << endl; }
};
int main() {
  Fraction f;  // <-- here
  return 0;
}

Group of answer choices
There is no constructor defined
Copy constructor is undefined
Default constructor is undefined
Constructor is defined as public
 
Question 9:
 
Find an incorrect definition of getter/setter for Fraction.
Group of answer choices
void setNumerator(int n) { numerator = n; }
void getNumerator() { return numerator; }
void setDenominator(int d) { denominator = d; }
int getDenominator() { return denominator; }
 
Question 10:
 

What would be the printout of the following code segment?

Fraction f(2, 3); 
f.display();

Group of answer choices
23
2 3
2,3
2/3
 
Question 11:
 

Suppose I added the following copy constructor to Fraction. Which statement will invoke this method?

Fraction(const Fraction& b) {
  denominator = b.denominator;
  numerator = b.numerator;
}

Group of answer choices
Fraction f(2, 3);
Fraction g = f;
Fraction h;
Fraction* j = nullptr;
 
Question 12:
 

Suppose I added the following overloaded operator method to Fraction. Which statement will invoke this method?

Fraction operator+(const Fraction& b) {
    Fraction o;
    o.denominator = denominator * b.denominator; 
    o.numerator = numerator * b.denominator + b.numerator * denominator; 
    return o;
}

Group of answer choices
Fraction f(2, 3);
Fraction g = f;
Fraction h;
Fraction h = f + g;
 
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education