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++)
for(int i=0; i<MAXSALARIED; i++)
cout<<"\nTotal to be paid"<<computeTotalSalaried(s1, MAXSALARIED);
    return 0;


#ifndef SALARIED_H
#define SALARIED_H

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


#endif // SALARIED_H


#include <iostream>
using namespace std;
#include "salaried.h"
void Salaried::inputDetails()
cout<<"Enter id"<<endl;
cout<<"Enter First Name"<<endl;
cout<<"Enter Surname"<<endl;
cout<<"Enter salary of employee"<<endl;
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.