Ако може малко помощ с една задача на C++, не съм много сигурен дали е вярна до сега и за функциите ако може някви разяснения
http://prikachi.com/images/223/7073223o.jpg
http://prikachi.com/images/224/7073224y.jpg
ето го кода ми, даже не знам дали е верен, но някой неща не знам как да ги напрая
Код:
#include<iostream>
#include<string>
#include<vector>
#include<fstream>
#include<algorithm>
#include<iterator>
using namespace std;
class CSalary{
string m_strProfession;
double m_dSalary;
public:
CSalary(){};//Podrazbirasht se konstruktor
CSalary(const string& strProfession,const double& dSalary){
m_strProfession=strProfession;
m_dSalary=dSalary;
}//Ekspliciten konstruktur
CSalary(const CSalary &ob){
m_strProfession=ob.m_strProfession;
m_dSalary=ob.m_dSalary;
}//Kopirasht konstruktur
string getProf(void)const{
return m_strProfession;
}
double getSalary(void)const{
return m_dSalary;
}
void setProf(const string&strProfession){
m_strProfession=strProfession;
}
void setSalary(const double&dSalary){
m_dSalary=dSalary;
}
friend ostream&operator<<(ostream&os,const CSalary&s){
os<<s.m_strProfession<<" "<<s.m_dSalary<<endl;
return os;
}
friend istream&operator>>(istream&is,CSalary&s){
is>>s.m_strProfession;
is>>s.m_dSalary;
return is;
}
CSalary&operator=(const CSalary&ob){
m_strProfession=ob.m_strProfession;
m_dSalary=ob.m_dSalary;
return *this;
}
bool operator<(const CSalary&s)const{
return(m_strProfession<s.m_strProfession);
}
bool operator==(const CSalary&s)const{
return(m_strProfession==s.m_strProfession);
}
double operator *(const CSalary&obj)
{
return m_dSalary*obj.m_dSalary;
}
}
class CCalcCorr
{
vector<CSalary*>m_vCity1;//danni za grad1
vector<CSalary*>m_vCity2;//danni za grad2
double m_dCorr;//korelacionen koeficent
CCalcCorr(const string& strFileName1,const string& strFileName2)
{
ifstream f(strFileName1.data());
if(!f)
throw "File Not Found!";
else
{
f>>m_dCorr;
copy(istream_iterator<CCalcCorr>(f),istream_iterator<CCalcCorr>(),back_inserter(m_vCity1));
sort(m_vCity1.begin(),m_vCity1.end());
}
ifstream ff(strFileName2.data());
if(!ff)
throw "File Not Found!";
else
{
ff>>m_dCorr;
copy(istream_iterator<CCalcCorr>(ff),istream_iterator<CCalcCorr>(),back_inserter(m_vCity2));
sort(m_vCity2.begin(),m_vCity2.end());
}
}
}