1.syntax error: identifier 'Technichian'
2.'='; cannot convert from char[] to char[20]
3.'{' missing old function header (old style format list?)
i'm not sure how to fix them now
#include<iostream>
#include<string.h>
using namespace std;
class RepairJob
{
void friend displayRepairJob(RepairJob rj, Technician tech);
private:
int jobNum;
int mo;
int day;
int yr;
double amount;
int techNum;
public:
RepairJob(int job, int m, int d, int y, double amt, int tech);
};
RepairJob::RepairJob(int job, int m, int d, int y, double amt, int tech)
{
jobNum = job;
mo = m;
day = d;
yr = y;
amount = amt;
jobNum = tech;
}
class Technician
{
friend void displayRepairJob(RepairJob rj, Technician tech);
private:
int techId;
char name[20];
public:
Technician(int id, char nm[]);
};
Technician::Technician(int id, char nm[])
{
techId = id;
name = nm;
}
class repairjob refers to class technician but has not seen it yet. Because these classes use each other, you need what is called a forward declaration. I haven't done that in a while so you may need a google it (I am short on time) but I think that just means put
class Technician;
at the top of the file.
I have low patience for [] notation in prototypes. * notation solves most of those types of problems (strings and vectors solve them much better).
Second, the error messages tell also which line the error is on. Details are important.
6:44: error: 'Technician' has not been declared
In constructor 'Technician::Technician(int, char*)':
38:6: error: incompatible types in assignment of 'char*' to 'char [20]'
At global scope:
41:1: error: expected unqualified-id before '{' token
45:11: error: '::main' must return 'int'
In function 'int main()':
48:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
48:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
Not a show-stopper.
The "Dunne" is a string literal constant. You give its address that takes a non-const pointer. The function could attempt to modify memory via that pointer. The "Dunne" is in memory that is not permitted modify.