SOSC 1375 Lecture 5: Main.cpp

26 views1 pages
Main.cpp
1#include"Employee.h"
2
3intmain()
4{
5cout<<"*****TestingEmployeeclass*****"<<endl;
6
7Employeee1;//ifnodefaultctorthenfollowingcompileerrormsg:
8//"error:nomatchingfunctionforcall
9//to'Employee::Employee()'"
10 cout<<e1.getName()<<endl;
11
12 Employeee2("John",4000.00);
13 //e1.getName()="Mary";//willbeerrorbecauseof
14 //constreturningetName
15 cout<<e2.getName()<<endl;
16
17 Employeearray1[2];//mustsupplyadefaultctorfor
18 //arrayelements
19 cout<<array1[0].getName()<<endl;
20 cout<<array1[1].getName()<<endl;
21
22 Employee*e3;
23
24 Employee*e4=newEmployee;//sameas"newEmployee();"
25 cout<<e4>getSalary()<<endl;
26 e4>setSalary(7000.00);
27 cout<<e4>getSalary()<<endl;
28
29 Employee*e5=newEmployee("Dave",6000.00);
30 cout<<(*e5).getName()<<endl;
31 deletee5;
32 e5=0;
33
34 Employee*array2=newEmployee[2];//mustsupplyadefaultctor
35 //forarrayelements
36 array2[0].getSalary();
37 cout<<array2[0].getSalary()<<endl;
38 cout<<array2[1].getSalary()<<endl;
39 delete[]array2;
40 array2=0;
41
42 Employee*e6=newEmployee("Fred",2000.00);
43 Employee*e7=newEmployee("Dennis",1000.00);
44 if(e6>richer(*e7))
45 {
46 cout<<"FredisricherthanDennis"<<endl;
47 }
48 deletee6;e6=0;
49 deletee7;e7=0;
50 }
51
Page1
Unlock document

This preview shows half of the first page of the document.
Unlock all 1 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers