Inheritance Lab :
1.1
(1)
(2)
(3)
1.2
1.
//test4_1.cpp
#include
public:
void setx(int i)
{x=i;}
Int getx()
{return x;} public:
int x;
};
class Derived:public Base{ public:
void sety(int i)
{y=i;}
int gety()
{return y;} void show()
{cout<<Base::x=<
#include
{
public: MyArray(int leng);
~MyArray{}; void Input();
void Display(string); protected:
int*alist; int length;
};
MyArray::MyArray(int leng)
{
if(leng<=0){cout<<error length; exit(1);}alist=new int [leng]; length=leng; if(alist==NULL){cout<<assign failure; exit(1);}cout<<MyArray<
}
int main()
{
MyArray a(5); a.Input();
a.Display();
return 0;
}
(2) SortArray MyArray
1
class SortArray : public MyArray
{
public:
void Sort();
SortArray(int leng):MyArray(leng)
{
cout<<SortArray<
Reviews
There are no reviews yet.