Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Find the errors in the following class and explain how to correct them #include

ID: 3546008 • Letter: F

Question

Find the errors in the following class and explain how to correct them



#include <iostream>

using namespace std;

class A {

      int num ;

      public :

             A(int x) {

                   num = x ; }

};

class B {

      string name ;

      A object ;

      B(string n,int x) {

               name = n ;

               object(x) ;

      }

}

int main () {

    B ob("Moh",435) ;

    system ("pause") ;

    return 0 ; }

#include <iostream>

using namespace std;

class A {

      int num ;

      public :

             A(int x) {

                   num = x ; }

};

class B {

      string name ;

      A object ;

      B(string n,int x) {

               name = n ;

               object(x) ;

      }

}

int main () {

    B ob("Moh",435) ;

    system ("pause") ;

    return 0 ; }

Explanation / Answer

#include <iostream>

using namespace std;

class A {

int num ;

public :

A(int x) {

num = x ; }

};

class B {

string name ;

public:

B(string n,int x) {

name = n ;

A object(x) ;

}

};

int main () {

B ob("Moh",435) ;

//system ("pause") ;

return 0 ; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote