AIM : TO create a program to show overriding Base class members in a Derived class. PROCEDURE : If we inherit a class into the derived class and provide a definition for one of the base class's function again inside the derived class, then that function is said to be overridden, and this mechanism is called Function Overriding. PROGRAM : #include using namespace std;
class Base { public: Base() : b(0) {} int get(); virtual void sayhello() { cout << "Hello from Base with b: " << b << endl; } private: int b; };
int Base::get() { sayhello(); return b; }
class Derived : public Base { public: Derived(double b_):b(b_){} void sayhello() { cout << "Hello from Derived with b: " << b << endl; } private: double b; };
int main() { Derived d(10.0); Base b = d;
cout << "Derived b: " << d.get() << endl; cout << "Base b: " << b.get() << endl; } Error : 0 Output : Hello from Derived with b: 10 Derived b: 0 Hello from Base with b: 0 Base b: 0 Result : I have successfully done my program.
AIM: To create a program using overriding base class in a derived PROCEDURE: In this program we inherit base class member function (void introduce) in a derived class .If we inherit base class into derived class then it is called overriding. PROGRAM: #include using namespace std; class person { public: void introduce() { cout<<"I am a person"<<endl; } }; class student:public person { public: void introduce() { cout<<"I am a student and i am awesome"<<endl; } }; int main() { student s; s.introduce(); return 0; } ERROR:0 OUTPUT: I am a student and i am awesome. RESULT: I have done my program successfully.
AIM: To create a program to show complexity and ambiguity in inheritance. PROCEDURE: In this c++ program there are two base class(one base class is teacher and another base class is student) and one derived class(person).Ambiguity arises in c++ when general rules leave the choice of more than one parent without a ambiguity criteria. PROGRAM: #include using namespace std; class teacher { protected: int x; public: void display() { cout<<"Enter the value of x:"; cin>>x; } }; class student { protected: int y; public: void display() { cout<<"Enter the value of y:"; cin>>y; } }; class person:public teacher,public student { public: void add() { cout<<"sum="<<x+y<<endl; } }; int main() { person obj; obj.student::display(); obj.teacher::display(); obj.add(); return 0; } ERROR:0 OUTPUT: Enter the value of x:22 Enter the value of y:12 Sum:34 RESULT:I have done my program successfully.
AIM: To create a program to show complexity and ambiguity in inheritance. PROCEDURE: Step 1 : Start the program. Step 2 : In this program, there are two base class i.e. sample and max. Step 3 : And one derived class i.e. derived. Step 4: when general rules leave the choice of more than one parent without a ambiguity criteria. Step 5 : End the program. PROGRAM: #include using namespace std; class sample { protected: int a; public: void getdata() { cout<<"Enter the value of a:"; cin>>a; } }; class max { protected: int b; public: void getdata() { cout<<"Enter the value of b:"; cin>>b; } }; class derived:public sample , public max { public: void product() { cout<<"product="<<a*b<<endl; } }; int main() { derived d; d.max::getdata(); d.sample::getdata(); d.product(); return 0; } ERROR : 0 OUTPUT : Enter the value of a:10 Enter the value of b:15 Product:150 RESULT:I have successfully done my program.
AIM:- To create a program to show overriding base class member in drived class. Procedure:- the both base class and derived class have a member function with same name and argument. If you create an object of the drive class and called member function which exist in both class(base,derived). PROGRAM:- #include using namespace std; class base { public: void show() { cout<<"it is a base class"<<endl; } }; Class derived :public base { public: void show() { cout<<"it is derived class and inherite the property of base class"<<endl; } }; int main() { derived prince; prince.show(); return 0; } ERROR:0 OUTPUT: it is a derived class and inherit the property of base class RESULT:I have successfully done my program.
AIM:- To create a program to show overriding base class member in drived class.
Procedure:- the both base class and derived class have a member function with same name and argument. If you create an object of the drive class and called member function which exist in both class(base,derived). PROGRAM:- #include using namespace std; class base { public: void show() { cout<<"it is a base class"<<endl; } }; Class derived :public base { public: void show() { cout<<"it is derived class and inherite the property of base class"<<endl; } }; int main() { derived prince; prince.show(); return 0; } ERROR:0 OUTPUT: it is a derived class and inherit the property of base class RESULT:I have successfully done my program.
AIM: Write a program to show complexity and ambugity in inheritance. Procedure: In this program we have used multilevel inheritance with same member function name and to solve the complexity faced by the compiler during run time we use scope resolution operator. PROGRAM: #include using namespace std; class grandpa { private: int height; public: void heightdata() { cout<<"grandpa is tall"<<endl;
public: void heightdata() { cout<<"Daddy is also tall"<<endl;
}
}; class me: public daddy {
public: void heightdata() { cout<<"But i am not so tall"<<endl; } void sports() { cout<<"I love sport"<<endl; } }; int main() { me obj; grandpa obj2; daddy obj3; obj2.petlove();
obj.grandpa::heightdata(); obj.daddy::heightdata(); obj.heightdata(); obj.sports(); } OUTPUT: grandpa is tall grandpa loves pet Daddy is also tall But i am not so tall I love sport ERROR: 0 RESULT: Executed program successfully
AIM : TO create a program to show overriding Base class members in a Derived class. Procedure: In this C++ program if we inherit a class into the derived class and provide a definition for one of the base class's function again inside the derived class, then that function is said to be overridden, and this mechanism is called Function Overriding. Program: #include using namespace std; class base { public: int a,b,c; void input() { cout<<"Enter two numbers"<>a>>b; } void calculation() { c=a+b; cout<<"Sum is: "<<c<<endl; } }; class derived: public base { public: void calculation() { c=a*b; cout<<"Product is: "<<c; } }; int main() { derived d; base b; d.input(); b.calculation(); //calling base class functions d.calculation(); //overriding the function return 0; } Error: 0 Output: Enter two numbers 45 45 Sum is: 4883904 Product is: 2025 Result: This program execute successfully
AIM: To create a program to show complexity and ambiguity in inheritance. Procedure: In this program we have used multilevel inheritance with same member function name and to solve the complexity faced by the compiler during run time we use scope resolution operator. PROGRAM: Program: #include using namespace std; class base1 { public: void display() { cout<<"Myself Zaira Zahid,"<<endl; } }; class base2 { public: void display() { cout<<"pursuing B-tech from NIMS University"<<endl; } }; class derived: public base1, public base2 { public: void show() { cout<<"Showing ambiguity is multiple inheritance"<<endl; } }; int main() { derived d; d.show(); d.base1::display(); d.base2::display(); return 0; } Error: No error found. Output: Showing ambiguity is multiple inheritance Myself Zaira Zahid, pursuing B-tech from NIMS University. Result: This program executed successfully.
i) Write a c++ program to show static member function and static member data. ii) Write a c++ program to show constructor, destructor, inheritance and dynamic memory allocation in same program.
COMPARISON OF IBM, GEPHI, TABLEAU, SIMBA, AZURE, LAMBDA, HADOOP, SPARK AND R IBM WATSON ANALYTICS: Watson Analytics is a smart data analysis and visualization service we can use to quickly discover patterns and meaning in our data – all on our own. With guided data discovery, automated predictive analytics and cognitive capabilities such as natural language dialogue, we can interact with data conversationally to get answers we understand. Whether we need to quickly spot a trend or we have a team that needs to visualize report data in a dashboard, Watson Analytics has we covered. Anything with textual data would be a perfect scenario for this product as the ultimate aim for it was to create an instance which would be able to process textual data just like the way humans might do it. It can definitely parse textual data really well. It has some great features associated with it for analyzing the textual data. We don't have to know real world coding ...
AIM : TO create a program to show overriding Base class members in a Derived class.
ReplyDeletePROCEDURE :
If we inherit a class into the derived class and provide a definition for one of the base class's function again inside the derived class, then that function is said to be overridden, and this mechanism is called Function Overriding.
PROGRAM :
#include
using namespace std;
class Base
{
public:
Base() : b(0) {}
int get();
virtual void sayhello()
{
cout << "Hello from Base with b: " << b << endl;
}
private:
int b;
};
int Base::get()
{
sayhello();
return b;
}
class Derived : public Base
{
public:
Derived(double b_):b(b_){}
void sayhello()
{
cout << "Hello from Derived with b: " << b << endl;
}
private:
double b;
};
int main()
{
Derived d(10.0);
Base b = d;
cout << "Derived b: " << d.get() << endl;
cout << "Base b: " << b.get() << endl;
}
Error : 0
Output :
Hello from Derived with b: 10
Derived b: 0
Hello from Base with b: 0
Base b: 0
Result :
I have successfully done my program.
AIM: To create a program using overriding base class in a derived
ReplyDeletePROCEDURE: In this program we inherit base class member function (void introduce) in a derived class .If we inherit base class into derived class then it is called overriding.
PROGRAM:
#include
using namespace std;
class person
{
public:
void introduce()
{
cout<<"I am a person"<<endl;
}
};
class student:public person
{
public:
void introduce()
{
cout<<"I am a student and i am awesome"<<endl;
}
};
int main()
{
student s;
s.introduce();
return 0;
}
ERROR:0
OUTPUT: I am a student and i am awesome.
RESULT: I have done my program successfully.
AIM: To create a program to show complexity and ambiguity in inheritance.
ReplyDeletePROCEDURE:
In this c++ program there are two base class(one base class is teacher and another base class is student) and one derived class(person).Ambiguity arises in c++ when general rules leave the choice of more than one parent without a ambiguity criteria.
PROGRAM:
#include
using namespace std;
class teacher
{
protected:
int x;
public:
void display()
{
cout<<"Enter the value of x:";
cin>>x;
}
};
class student
{
protected:
int y;
public:
void display()
{
cout<<"Enter the value of y:";
cin>>y;
}
};
class person:public teacher,public student
{
public:
void add()
{
cout<<"sum="<<x+y<<endl;
}
};
int main()
{
person obj;
obj.student::display();
obj.teacher::display();
obj.add();
return 0;
}
ERROR:0
OUTPUT:
Enter the value of x:22
Enter the value of y:12
Sum:34
RESULT:I have done my program successfully.
AIM: To create a program to show complexity and ambiguity in inheritance.
ReplyDeletePROCEDURE:
Step 1 : Start the program.
Step 2 : In this program, there are two base class i.e. sample and max.
Step 3 : And one derived class i.e. derived.
Step 4: when general rules leave the choice of more than one parent without a ambiguity criteria.
Step 5 : End the program.
PROGRAM:
#include
using namespace std;
class sample
{
protected:
int a;
public:
void getdata()
{
cout<<"Enter the value of a:";
cin>>a;
}
};
class max
{
protected:
int b;
public:
void getdata()
{
cout<<"Enter the value of b:";
cin>>b;
}
};
class derived:public sample , public max
{
public:
void product()
{
cout<<"product="<<a*b<<endl;
}
};
int main()
{
derived d;
d.max::getdata();
d.sample::getdata();
d.product();
return 0;
}
ERROR : 0
OUTPUT :
Enter the value of a:10
Enter the value of b:15
Product:150
RESULT:I have successfully done my program.
This comment has been removed by the author.
ReplyDeleteAIM:- To create a program to show overriding base class member in drived class.
ReplyDeleteProcedure:- the both base class and derived class have a member function with same name and argument.
If you create an object of the drive class and called member function which exist in both class(base,derived).
PROGRAM:-
#include
using namespace std;
class base
{
public:
void show()
{
cout<<"it is a base class"<<endl;
}
};
Class derived :public base
{
public:
void show()
{
cout<<"it is derived class and inherite the property of base class"<<endl;
}
};
int main()
{
derived prince;
prince.show();
return 0;
}
ERROR:0
OUTPUT: it is a derived class and inherit the property of base class
RESULT:I have successfully done my program.
AIM:- To create a program to show overriding base class member in drived class.
ReplyDeleteProcedure:-
the both base class and derived class have a member function with same name and argument.
If you create an object of the drive class and called member function which exist in both class(base,derived).
PROGRAM:-
#include
using namespace std;
class base
{
public:
void show()
{
cout<<"it is a base class"<<endl;
}
};
Class derived :public base
{
public:
void show()
{
cout<<"it is derived class and inherite the property of base class"<<endl;
}
};
int main()
{
derived prince;
prince.show();
return 0;
}
ERROR:0
OUTPUT: it is a derived class and inherit the property of base class
RESULT:I have successfully done my program.
AIM: Write a program to show complexity and ambugity in inheritance.
ReplyDeleteProcedure: In this program we have used multilevel inheritance with same member function name and to solve the complexity faced by the compiler during run time we use scope resolution operator.
PROGRAM:
#include
using namespace std;
class grandpa
{
private:
int height;
public:
void heightdata()
{
cout<<"grandpa is tall"<<endl;
}
public:
void petlove()
{
cout<<"grandpa loves pet"<<endl;
}
};
class daddy:public grandpa
{
public:
void heightdata()
{
cout<<"Daddy is also tall"<<endl;
}
};
class me: public daddy
{
public:
void heightdata()
{
cout<<"But i am not so tall"<<endl;
}
void sports()
{
cout<<"I love sport"<<endl;
}
};
int main()
{
me obj;
grandpa obj2;
daddy obj3;
obj2.petlove();
obj.grandpa::heightdata();
obj.daddy::heightdata();
obj.heightdata();
obj.sports();
}
OUTPUT:
grandpa is tall
grandpa loves pet
Daddy is also tall
But i am not so tall
I love sport
ERROR:
0
RESULT: Executed program successfully
AIM : TO create a program to show overriding Base class members in a Derived class.
ReplyDeleteProcedure: In this C++ program if we inherit a class into the derived class and provide a definition for one of the base class's function again inside the derived class, then that function is said to be overridden, and this mechanism is called Function Overriding.
Program:
#include
using namespace std;
class base
{
public:
int a,b,c;
void input()
{
cout<<"Enter two numbers"<>a>>b;
}
void calculation()
{
c=a+b;
cout<<"Sum is: "<<c<<endl;
}
};
class derived: public base
{
public:
void calculation()
{
c=a*b;
cout<<"Product is: "<<c;
}
};
int main()
{
derived d;
base b;
d.input();
b.calculation(); //calling base class functions
d.calculation(); //overriding the function
return 0;
}
Error: 0
Output: Enter two numbers
45
45
Sum is: 4883904
Product is: 2025
Result: This program execute successfully
AIM: To create a program to show complexity and ambiguity in inheritance.
ReplyDeleteProcedure: In this program we have used multilevel inheritance with same member function name and to solve the complexity faced by the compiler during run time we use scope resolution operator.
PROGRAM:
Program:
#include
using namespace std;
class base1
{
public:
void display()
{
cout<<"Myself Zaira Zahid,"<<endl;
}
};
class base2
{
public:
void display()
{
cout<<"pursuing B-tech from NIMS University"<<endl;
}
};
class derived: public base1, public base2
{
public:
void show()
{
cout<<"Showing ambiguity is multiple inheritance"<<endl;
}
};
int main()
{
derived d;
d.show();
d.base1::display();
d.base2::display();
return 0;
}
Error: No error found.
Output: Showing ambiguity is multiple inheritance
Myself Zaira Zahid,
pursuing B-tech from NIMS University.
Result: This program executed successfully.