I am having 4 errors with the main program and i dn't know how to slove it anyone to help me how to solve the errors and how the codes was suppose to be correctly typed:
1.error: 'salaried' was not declared in this scope (line 5)
2.error: expected primary expression before 'int' (line 5)
3.error: expression list treated as compound expression in initializer [-fpermissive](line 5)
4.error: expected ',' or ';' before '{' token (line 6)

here are my codes for the main.cpp

#include <iostream>
#include "salaried.h"
using namespace std;

float computeTotalSalaried(Salaried e[], int sz)
{
float totalwage = 0;
for(int i=0; i<sz; i++)
{
totalwage = totalwage + e[i].getAmountPaid();
}
return totalwage;
}
int main()
{
const int MAXSALARIED = 2;
Salaried s1[MAXSALARIED];
cout<<"Processing details of Salaried Employee"<<endl;
for(int i=0; i<MAXSALARIED; i++)
s1[i].inputDetails();
for(int i=0; i<MAXSALARIED; i++)
s1[i].displayDetails();
cout<<"\nTotal to be paid"<<computeTotalSalaried(s1, MAXSALARIED);
    return 0;
}

salaried.h:

#ifndef SALARIED_H
#define SALARIED_H


class salaried
{
    public:
        char id[10];
        char fname[100];
        char sname[100];
        float salary;
    private:
        void inputDetails();
        void displayDetails();
        float getAmountPaid();

};

#endif // SALARIED_H

salaried.cpp:

#include <iostream>
using namespace std;
#include "salaried.h"
void Salaried::inputDetails()
{
cout<<"Enter id"<<endl;
cin.getline(id,10,'\n');
cout<<"Enter First Name"<<endl;
cin.getline(fname,100,'\n');
cout<<"Enter Surname"<<endl;
cin.getline(sname,100,'\n');
cout<<"Enter salary of employee"<<endl;
cin>>salary;
cin.ignore();
}
void Salaried::displayDetails()
{
cout<<"ID :"<<id;
cout<<"\tSurname :"<<sname;
cout<<"\tFirstname :"<<fname;
cout<<"Salary of employee<<salary;
}
float Salaried::getAmountPaid()
{
return salary;
}

Edited 2 Years Ago by nitish.mohiputlall: misspelling

C++ is case sensitive. Change line 5 of your header file from class salaried to class Salaried (Note the uppercase S) and that problem should go away!

Effectively you have declared a class called salaried in your header, yet your cpp file contains definitions for Salaried. So the compiler is complaining that it doesn't know what 'salaried' is.

Also FYI: It looks as if you have the private and public members of your class the wrong way around. Shouldn't the member functions be public? and the data members private? You might want to review that! :)

Your class is named salaried in the header, but Salaried elsewhere. See the difference?

This question has already been answered. Start a new discussion instead.