Software-help

Software-help

Share

Page for IT students

13/04/2016

// Inheritance code
// A Person class is created with 2 data members (access specifier is protected not private)
// A Student class is created with 2 data members and it inherits Person class
// So all public & protected data members are accessible in Student class.


using namespace std;

class Person{
protected:
string name;
char gender;

public:
Person()
{
name = "";
gender = ' ';
}

Person(string t_name, char t_gender)
{
name = t_name;
gender = t_gender;
}

void set_Person(string t_name, char t_gender)
{
name = t_name;
gender = t_gender;
}

string get_name()
{
return name;
}

char get_gender()
{
return gender;
}
};

class Student : public Person{
private:
int std_id;
string std_degree;
public:
Student()
{
std_id = 0;
std_degree = "";
}

Student(int t_sid, string t_s_degree)
{
std_id = t_sid;
std_degree = t_s_degree;
}

void set_Student(int t_sid, string t_s_degree)
{
std_id = t_sid;
std_degree = t_s_degree;
}

int get_std_id()
{
return std_id;
}

string get_std_degree()
{
return std_degree;
}

};

int main()
{

// In main 2 different Person objects are created and displayed.
Person p1;
p1.set_Person("Zahid", 'M');

Person p2("Ayesha", 'F');

cout

22/11/2015

Single link list
*********************************************
//Author : Qaisar Abbas Khokhar Bharmi


using namespace std;
struct bharmi
{
int num;
bharmi *next;
};
bharmi *head=NULL;
void addData(int);
void printData();
int main()
{

int a,b;
coutb;
for(int i=1;inext;
}

crnt->next=temp;
temp->next=NULL;
}

}

void printData()
{
cout

Want your business to be the top-listed Computer & Electronics Service in Lahore?
Click here to claim your Sponsored Listing.

Website

Address


Lahore