Not sure what my errors mean or how to fix,
Sep 4, 2014 at 10:48pm UTC
This is my first lab in my object orientated programming course and im having a lot of issues so far but ive managed to make it this far. When attempting to compile this I get three errors:
1>project 1.cpp(101): error C2065: 'Henry' : undeclared identifier
1>project 1.cpp(101): error C2065: 'Smith' : undeclared identifier
Could some help me fix and understand what my issues are?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace System;
using namespace std;
class Employee
{
public :
Employee(); //constructor
void printLastFirst();
void printFirstLast();
void incrementAge();
void giveRaise(double );
void printInfo();
void setName(string, string);
void setAge(int );
void setSalary(double );
void setDepartmentID(int );
private :
int age;
int departmentID;
string firstName;
string lastName;
double salary;
double raise;
};
Employee::Employee()
{
age = departmentID = 0;
firstName = lastName = "Unknown" ;
salary = 2000.0;
}
void Employee::setName(string l, string f)
{
firstName = f;
lastName = l;
}
void Employee::setAge(int A)
{
age = (A > 0 && A < 130) ? A : 0;
}
void Employee::setSalary(double s)
{
salary = (s >= 0 && s <= 1000000) ? s : 2000.0;
}
void Employee::setDepartmentID(int i)
{
departmentID = (i >= 0) ? i : 0;
}
void Employee::printLastFirst()
{
cout << lastName << "," << firstName << "\n" ;
}
void Employee::printFirstLast()
{
cout << firstName << " " << lastName << "\n" ;
}
void Employee::incrementAge()
{
if (age < 130)
{
++age;
}
cout << age << "\n" ;
}
void Employee::giveRaise(double r)
{
raise = (r*salary);
cout << raise << "\n" ;
}
void Employee::printInfo()
{
cout << "Employee Name: " << firstName << " " << lastName << "\n" ;
cout << "Employee Age: " << age << "\n" ;
cout << "Employee ID: " << departmentID << "\n" ;
cout << "Employee Salary " << "$" << salary << "\n" ;
}
int main()
{
Employee a;
cout << "The default values are: \n" ;
a.printInfo();
a.setName(Henry, Smith);
a.printLastFirst();
system("pause" );
}
Last edited on Sep 4, 2014 at 11:09pm UTC
Sep 4, 2014 at 11:13pm UTC
1>project 1.cpp(101): error C2065: 'Henry' : undeclared identifier
1>project 1.cpp(101): error C2065: 'Smith' : undeclared identifier
You need to use double quotes for strings.
1>project 1.cpp(102): error C3867: 'Employee::printLastFirst': function call missing argument list
Looks like you forgot something there too...
Sep 4, 2014 at 11:18pm UTC
use double quotes for string.
a.setName("Henry" ,"smith" );
Topic archived. No new replies allowed.