Adil Khan 7 years ago

Basic OOP Programs

Practical No 1:

 

#include

using namespace std;

class myClass{

            public:

            void memFunc(){

                        cout<<"Hello every One!";

            }

};

int main(){

             

            myClass obj;

            obj.memFunc();

            return 0;

}


Practical No 2:

 

#include

using namespace std;

class myClass{

            private:

            int age;

            public:

            void getAge(){

                        cout<<"Enter Your Age :";

                        cin>>age;

            }

            void showAge(){

                        cout<<"Your Age is "<

            }

};

int main(){

             

            myClass obj;

            obj.getAge();

            obj.showAge();

            return 0;

}


Practical No 3:

 

#include

using namespace std;

class myClass{

            private:

            int sum;

            public:

            void add(int x,int y,int z){

                        sum = x+y+z;

                        cout<<"Sum of "<

            }

            void add(int x,int y){

                        sum = x+y;

                        cout<<"Sum of "<

            }

};

int main(){

             

            myClass obj;

            obj.add(5,44);

            obj.add(5,3,5);

            return 0;

}


Practical No 4:

 

#include

using namespace std;

class myClass{

            private:

            int x;

            public:

            myClass(){

                        cout<<"Hello this is a constructor!";

                        x=3;

            }

            void memFunc(){

                        cout<<" This is a member function and x = "<

            }

};

int main(){

             

            myClass obj;

            obj.memFunc();

            return 0;

}


Practical No 5:

 

#include

using namespace std;

class myClass{

            private:

            int x;

            public:

            myClass(){

                        cout<<"Hello this is a constructor!";

                        x=3;

            }

            ~myClass(){

                        cout<<" Hello this is a destructor!";

            }

};

int main(){

             

            {

            myClass obj;

            }

            return 0;

}


Practical No 6:

 

#include

using namespace std;

class A{

            protected:

            int x;

            public:

            void setX(int a){

                        x = a;

            }

};

class B:public A{

            public:

            void getX(){

                        cout<<"x = "<

            }

};

int main(){

             

            B obj;

            obj.setX(4);

            obj.getX();

            return 0;

            }

 

Download the File Below for all Programs  Basic OOP Programs _ 0.pdf

Download: Basic OOP Programs _ 0.pdf

0
1.2K
IOT Based Smart Waste Management System in Pakistan

Smart waste management is an idea where we can control lots of problems which disturbs the...

1675638330.png
Adil Khan
1 year ago
QR CODE BASED ENTRY AND EXIT CONTROL SYSTEM

In&nbsp; this&nbsp; project,&nbsp; a&nbsp; QR&nbsp; Code-based&nbsp; Entry&nbsp; and&nbsp;...

1675638330.png
Adil Khan
1 year ago
Performance Analysis and Monitoring of Smart Energy Meter using IOT

The Internet of things (IOT) concept enables us to connect the normal day to day devices w...

1675638330.png
Adil Khan
1 year ago
Smart Air Purifier

Purpose: This project's core purpose is to fulfill the FYP requirement to complete the deg...

1675638330.png
Adil Khan
1 year ago
Traffic Light System Control Through Image Processing

Traffic jam issues increasing day by day due to the increase in population. A general traf...

1675638330.png
Adil Khan
1 year ago