AQ2a.h:14:11: error: ‘double Job::getBaseprice()’ is private AQ2c.cpp:25:37: error: within this context

$ g++ -o trial AQ2a.h AQ2b.cpp AQ2c.cpp
AQ2a.h: In function ‘int main()’:
AQ2a.h:14:11: error: ‘double Job::getBaseprice()’ is private
AQ2c.cpp:25:37: error: within this context


Help me with the error. Spend more than half a day on it.
Many Thanks in advance.

error causing line is in bold & underlined.

Aq2a.h = i swhere class is dclared
Aq2b.cpp = class implementation
Aq2c.cpp = main program


///////////////////
//AQ2a.h
//////////////////
#include<iostream>
#include <string>
#include <iomanip>

using namespace std;

// class declaration section

class Job

{
private:

int jobNum; //job number

double jobHour; // job hours

double hourRate; // rate per hour

public:

Job(); // user defined default constructor

void display(); // display respective data member

void setJob (int JobNum, double JobHour, double HourRate ); // set all data members

double getBaseprice(); // to calculate base price


};


class JobBid

{

public:

int bidID; //job bid ID

Job bidJob; // job hours

double priceQuote; // rate per hour


public:

JobBid(); // user defined default constructor

void setJobBid (int, Job, double ); // set all data members

int operator<(JobBid&); // to calculate base price

void displayJobBid(); // display respective data members

};



/////////////////////////////////////////////////////AQ2b.cpp///////////////////
#include"AQ2a.h"



//class implementation section
Job::Job()
{
jobNum =0;
jobHour = 0.0;
hourRate = 0.0;
}

void Job::setJob(int JobNum, double JobHour, double HourRate)
{
jobNum = JobNum;
jobHour = JobHour;
hourRate = HourRate;
}

double Job::getBaseprice()
{
double a;
a = (hourRate*jobHour);
return a;
}


void Job::display()
{

cout <<"Job No: "<<jobNum
<<"\nJob Hour: "<<jobHour
<<"\nHourly Rate: "<<hourRate<<endl;
cout<< "Base Price : "<<getBaseprice()<<endl;

}


//class implementation section
JobBid::JobBid()
{
bidID = 0;
Job bidJob;
priceQuote = 0.0;
}

void JobBid::setJobBid(int BidID, Job BidJob, double PriceQuote)
{
bidID = BidID;
bidJob = BidJob;
priceQuote = PriceQuote;
}


void JobBid::displayJobBid()
{
cout.precision(2);
cout << fixed <<"\nBid ID "<<bidID<<"\t";
if (priceQuote == -1)
cout <<"Price Quote : Price Quote lower than Base Price"<<endl;
else
cout <<"Price Quote :"<<priceQuote<<endl;
bidJob.Job::display();
}


int JobBid::operator<(JobBid& a)
{
if ( a.priceQuote > 10 )
{
return 1;
} else
return 0;

}

//int main ()
//{
//JobBid a;
//static Job a1;
//a1.setJob(1,1000,10);
//a.setJobBid(1,a1,10.0);
//a.displayJobBid();
//static double BasePrice;
//return 0;
//}

////////////////////////////////////////////////////Aq2c.cpp////////////////////////
#include"AQ2a.h"



int main()
{
JobBid highest;
Job jobA;
int x,n,njobs;
static int loop =0;
double t,r,price;
char sentinel = 'X';
double lowprice = 10000;

while (loop == 0)
{
cout<<"Enter job number ";
cin>>x;
cout<<"Enter job hour ";
cin>>t;
cout<<"Enter hourly rate ";
cin>>r;
jobA.setJob(x,t,r);

lowprice = jobA.getBaseprice();


cout<<"Enter no of job bids ";
cin>>n;
JobBid jobBids[n-1];
int quote_price[n-1];
int i;

for (i=0;i<n;i++)
{
cout<<"Enter price quote ";
cin>>quote_price[i];
}

for (i=0;i<n;i++)
{
if (quote_price[i] < lowprice)
quote_price[i] = -1;
}

for (i=0;i<n;i++)
{
jobBids[i].setJobBid(i+1,jobA,quote_price[i]);
}


cout<<"\nThe "<<n<<" job bids are : \n";

for (i=0;i<n;i++)
{
jobBids[i].displayJobBid();
}

cout<<"==============================\n";
cout<<"This season, the highest price quoted for this job is: \n";

for (i=0;i<n;i++)
{
int temp =0;
if ( quote_price[i] > temp)
{
temp = quote_price[i];
njobs = i;
}
}

jobBids[njobs].displayJobBid();

cout<<"Enter 'E' to exit, any other char to continue...";
cin>>sentinel;
if (sentinel == 'E' || sentinel == 'e' )
loop =1;
else
loop = 0;
}
return 0;

}

http://www.eelis.net/iso-c++/testcase.xhtml (I don't care for point 9)

PS: how is that you know how to bold, but fail to use code tags
Topic archived. No new replies allowed.