Junior — Senior
Find and fix the errors in this C++ code
livecode
Task condition
In this task, you need to identify and fix issues in the following C++ program fragment. Pay attention to the correctness of inheritance and calling base class methods.
# include <iostream>
using namespace std;
class RawHardDisk {
public:
RawHardDisk() {
cout << "RawHardDisk constructor called" << endl;
}
void attach() {
cout << "Disk attached" << endl;
}
};
class CBTHardDisk: public RawHardDisk {
public:
CBTHardDisk() {
cout << "CBTHardDisk constructor called" << endl;
}
};
class SCSIHardDisk: public RawHardDisk {
public:
SCSIHardDisk() {
cout << "SCSIHardDisk constructor called" << endl;
}
};
class OVirtHardDisk: public SCSIHardDisk, public CBTHardDisk {}
}
int main() {
OVirtHardDisk disk;
disk.attach();
return 0;
}
Fix the code so that it compiles and correctly outputs messages about constructor calls and the attach method.