CODE FOR + OPERATOR OVER LOADING C++

 PROBLEM STATEMENT: ADD 2 OBJECTS AND ADD INTO OTHER. CODE: #include<iostream> using namespace std; class Experience { private: int days; int month; double year; public: Experience() { } Experience(int a,int b,double c) { days = a; month = b; year = c; } Experience operator +(Experience E) { Experience E1; E1.days = days + E.days; E1.month = month + E.month; E1.year = year + E.year; return E1; } void display() { cout << "\nDAYS\t" << days << "\nMONTHS\t" << month << "\nYEAR\t" << year << endl; } }; int main() { Experience e1(2, 12, 2), e2(1, 12, 4), e3; e3 = e1 + e2; cout << "showing data of 1st Experience\n"; e1.display(); cout << "\n\n\n\n"; cout << "showing data of 2nd Experience\n"; e2.display(); cout << "\n\n\n\n"; cout << "showing data of sum of Experiences\

Employee program using nested structures in c++

 

CODE:

#include<iostream>

#include<string>

using namespace std;

struct Employeedata {

string name;

int yearofeducation;

};

struct check {

int experience;

string DOB;

int age;

Employeedata d;

};

int main()

{

check c1;

cout << "ENTER YOUR DATA\nNAME\nDOB\nage\nYEAROFEDUCATION\nEXPERIENCE\n";

cin >> c1.d.name >> c1.DOB>>c1.age >> c1.d.yearofeducation >> c1.experience;

cout << "checking you eligibility......................\n";

if (c1.experience < 2 && c1.d.yearofeducation > 16)

{

cout << "you are FRESH GRADUATE AND YOU ARE ELIGIBLE OF INTERVIEW\n";

}

else if (c1.age>50 && c1.d.yearofeducation < 16)

{

cout << "you are not eligible for post!\n";

}

else if (c1.d.yearofeducation > 18)

{

cout << "you are eligible for managerial position\n";

}

else

{

cout << "pls enter valid answer\n";

}

}

Comments

Popular posts from this blog

CODE FOR CAR AND BIKE MANAGEMENT USING(Virtual functions) C++

NESTED LOOPS IN C++