C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
Expert Solution & Answer
Book Icon
Chapter 13, Problem 18SA

Explanation of Solution

The following code shows the error and the corrected statement in the program:

class discover //Line 1

{ //Line 2

    friend discover operator+(const discover& a,

        const discover& b); //Line 4 - corrected version

        //the function must be declared as a friend function

        //Returns the object containing the

        //sum of the corresponding members

        //of the objects a and b...

Blurred answer
Students have asked these similar questions
class A {protected int x1,y1,z; public: A(a, b,c):x1(a+2),y1(b-1),z(c+2) { for(i=0; i<5;i++) x1++; y1++;z++;}}; class B {protected: int x,y; public: B(a,b):x(a+1),y(b+2) { for(i=0; i<5;i++) x+=2; y+=1;}}; class D:public B, virtual public A { private: int a,b; public: D(k,m,n): a(k+n), B(k,m),b(n+2),A(k,m,n) { a=a+1;b=b+1;}}); int main() {D ob(4,2,5);} what the values of x1,y1 and z
public class date {  private int day; // from 1 to 31  private int month; // from 1 to 12                 private int year; // from 2000 upwards                 public void advance (); // move to next day }; Implement a constructor that initializes new objects of date class to be set to the 1st of January 2000. Implement setters for day, month, and year. Implement the advance method, which moves to the next day, ensuring that all data members are updated appropriately.
class Base { public: int x, y: public: Base(int i, int j) { x = i; y = j; }}; class Derived : public Base public: Derived (int i, int j) { x = i; y = j; void display() {cout « x <<" "<< y; }}; int main(void) { Derived d(5, 5); d.display(); return e; Error O X=5,Y=5 X-0,Y=0 None of the above Other:
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning