0% found this document useful (0 votes)
28 views

Addition of Complex No.: Student Details Operator - Unary

This document contains code snippets from multiple C++ programs. It includes code defining classes for student details, complex number addition, unary operators, employee details, template swapping, and using friend functions. The code snippets define class structures, member functions to get and display data, operator overloading, and main functions to test the code.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Addition of Complex No.: Student Details Operator - Unary

This document contains code snippets from multiple C++ programs. It includes code defining classes for student details, complex number addition, unary operators, employee details, template swapping, and using friend functions. The code snippets define class structures, member functions to get and display data, operator overloading, and main functions to test the code.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

char name[20],address[30]; y=temp; } a=25,b=40; }

int dt,m,y,age,salary,empno; void fun(int m,int n,float a, friend float mean(sample


STUDENT DETAILS ADDITION OF COMPLEX NO. public : float b) { s); };
#include<iostream.h> #include<iostream.h> OPERATOR -UNARY void getdata(); cout<<"\n m and n before float mean(sample s)
#include<conio.h> #include<conio.h> #include<iostream.h> void display(); swap"<<m<<" "<<n; { return
#include<string.h> class complex #include<conio.h> }; swap(m,n); float(s.a+s.b)/2;
class student { class space void employee :: getdata() cout<<"\n m and n after }
{ int img,real; { { swap"<<m<<" "<<n; int main()
private: public: int x; cout<<"\n enter name:"; cout<<"\n a and b before {
char name[20]; void set(int r,int i) int y; cin>>name; swap"<<a<<" "<<b; clrscr();
int age,m1,m2,m3,total,avg; { int z; cout<<"enter age:"; swap(a,b); sample x;
public : real=r; public: cin>>age; cout<<"\n a and b after x.setvalue();
void getdata(); img=i; void getdata(int a,int b,int c); cout<<"enter salary:"; swap"<<a<<" "<<b; cout<<"mean
void display(); } void display(void); cin>>salary; } int main() { value="<<mean(x)<<"\n";
}; friend void sum(complex void operator-(); cout<<"enter employee no:"; clrscr(); getch();
void student :: getdata() c1,complex c2) }; cin>>empno; fun(100,200,11.22,33.21); return 0;
{ { Voidspace::getdata(int a,int b,int c) cout<<"enter the getch(); return 0; } }
cout<<"enter the name:"; int e,b; { date of joining:";
cin>>name; e=c1.real+c2.real; x=a; cin>>dt>>m>>y;
cout<<"enter the age:"; cout<<e<<"+"; y=b;
cin>>age; b=c1.img+c2.img; z=c;
total=(m1+m2+m3); cout<<b<<"j"; }
avg=(total/3);
}

SWAPPING USING TEMPLADE


FRIEND FUNCTION
EMPLOYEE DETAILS #include<iostream.h>
#include<iostream.h> #include<conio.h> #include<iostream.h>
#include<conio.h> template<class t> #include<conio.h>
#include<string.h> void swap(t &x,t &y) class sample
class employee { float temp; { int a,b;
{ temp=x; public:
private : x=y; void setvalue() {

You might also like