This ones giving me problems... I can't see why the parameters aren't matching up. Help? PATY.
Code:
Error Message:Code:#include<iostream> #include<conio.h> using namespace std; class Worker { private: int idNum; char lastName[20]; char firstName[20]; double salary; public: void setIdNum(int id); void setLastName(char last); void setFirstName(char first); void setSalary(double payRate); void displayWorker(); }; void Worker::setIdNum(int id) { if(id< 0 || id > 999) idNum = 0; else idNum = id; } void Worker::setLastName(char last) { strcpy(lastName, last); } void Worker::setFirstName(char first) { strcpy(firstName, first); } void Worker::setSalary(double payRate) { if (payRate <= 5.75 || payRate > 99.99) salary = 5.75; else salary = payRate; } void Worker::displayWorker() { cout<<"ID #"<<idNum<<" Name: "<<firstName<<" "<<lastName <<" Salary: $"<<salary<<endl; } void main() { Worker aWorker; aWorker.setIdNum(333); aWorker.setLastName("Vasquez"); aWorker.setFirstName("Juan"); aWorker.setSalary(15.65); aWorker.displayWorker(); std::cin.clear(); std::cin.ignore(); getchar(); }
1>c:\users\user\documents\visual studio 2010\projects\debug 5\debug 5\de.cpp(31): error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\user\documents\visual studio 2010\projects\debug 5\debug 5\de.cpp(35): error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\user\documents\visual studio 2010\projects\debug 5\debug 5\de.cpp(56): error C2664: 'Worker::setLastName' : cannot convert parameter 1 from 'const char [8]' to 'char'
1> There is no context in which this conversion is possible
1>c:\users\user\documents\visual studio 2010\projects\debug 5\debug 5\de.cpp(57): error C2664: 'Worker::setFirstName' : cannot convert parameter 1 from 'const char [5]' to 'char'
1> There is no context in which this conversion is possible
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.92
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
P.S. Like my post before this, it is homework but it's a program that I've had to fix the problems for and it was worse than this when I started. I've only used this forum as a last resort when I'm absolutely stuck. Thanks again.