錯誤C2784:「的std :: basic_ostream < _Elem,_Traits> &的std ::操作< <(STD :: basic_ostream < _Elem,_Traits> &,常量性病: :basic_string < _Elem,_Traits,_Alloc> &)':>無法爲'std :: basic_ostream < _Elem,_Traits> &'從std :: string'c:\ documents和settings \ rcs \ my推導模板參數文件\ visual studio 2010 \ projects ...在每一行收到錯誤我已經使用<<
代碼是:
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include "Pacient.h"
using namespace std;
void ruajKartele(Pacient patient)
{
int mosha;
char gjinia;
string foo=patient.getEmer();
string skedar=foo;
ofstream file;
file.open(skedar, ios::app);
skedar<<foo+"\n";
mosha=patient.getMosha();
gjinia=patient.getGjinia();
foo=patient.getDiagnoza();
skedar<<mosha<<"\n"<<gjinia<<"\n"<<foo<<"\n";
foo=patient.getPrognoza();
skedar<<foo+"\n";
skedar<<"-----\n"; //5
skedar.close();
}
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
//Pacient structure:
#include <string>
class Pacient
{
protected:
std::string emer;
int mosha;
char gjinia;
std::string diagnoza;
std::string prognoza;
public:
Pacient(void);
~Pacient(void);
void setEmer(std::string);
void setMosha (int);
void setGjinia(char);
void setDiagnoza(std::string);
void setPrognoza(std::string);
std::string getEmer(void);
int getMosha(void);
char getGjinia(void);
std::string getDiagnoza(void);
std::string getPrognoza(void);
};
我之前忘了提及skedar.close()。我現在添加它。爲你+1! :) – batbrat 2012-01-15 10:22:34
非常感謝你!,我一直在與一些項目工作了很長時間,我的眼睛顯然已經失明! 我不能告訴你剛纔的幫助! – Vinset 2012-01-15 10:22:59