Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Advertencia estricta: Sin IA . Se necesita respuesta urgente. AX 0 9 Question 2 in c + + A . In detail, explain the mistakes

Advertencia estricta: Sin IA. Se necesita respuesta urgente. AX09 "Question 2 in c++
A. In detail, explain the mistakes in the following program
#include
using namespace std;
class A
{
public:
void set_value(int x){ value = x;
} protected: int value;
};
class B public class A
{
public:
int get_value() const
{
return value;
}
}
int main()
{
A a;
B b;
a.set_value(10);
cout <<The value is: << a.value << endl;
b.set_value(12);
cout <<The value is: << b.get_value()<< endl;
return 0;
}
B. In detail, explain the mistakes in the following program
#include
using namespace std;
class A
{
public:
void set_value(int x)
{
value = x;
}
int value;
};
class B protected class A {
public:
int get_value() const
{
return value;
}
};
int main()
{
B b;
b.set_value(10);
cout <<The value is: << b.get_value()<< endl;
return 0;
}"

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions