class TenNums { private:     int *p;  public:     TenNums() {         p = new int[10];          for (

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

class TenNums {
private:
    int *p; 
public:
    TenNums() {
        p = new int[10]; 
        for (int i = 0; i < 10; i++) p[i] = i; 
    }
    void display() { for (int i = 0; i < 10; i++) cout << p[i] << " "; }
};
int main() {
    TenNums a;  
    a.display();  
    TenNums b = a;  
    b.display();  
    return 0;
}

Continuing from Question 4, let's say I added the following overloaded operator method to the class. Which statement will invoke this method?

TenNums TenNums::operator+(const TenNums& b) {
  TenNums o;
  for (int i = 0; i < 10; i++) o.p[i] = p[i] + b.p [i];
  return o;
}

Group of answer choices
TenNums a;
TenNums b = a;
TenNums c = a + b;
TenNums c = a.add(b);
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT