을 제기 나는 다음과 같은 코드가 있습니다부스트 파이썬 옵션 오류
//test.cpp
#include <Physical_file.h>
#include <boost\python.hpp>
using namespace boost::python;
using namespace FMS_Physical;
BOOST_PYTHON_MODULE(python_bridge)
{
class_<Physical_file, boost::noncopyable>("pf")
.def(init<const string&, optional<int, const string&>>())
;
}
//Physical_file.h
#include <fstream>
#include "tools.h"
using namespace std;
namespace FMS_Physical
{
class Physical_file
{
public:
fstream filefl;
string workingDir;
string fileName;
int fileSize;
block currBlock;
block FHBuffer;
bool opened;
string openMode;
/************
functions
************/
Physical_file(void);
Physical_file(const string &FileName, int FileSize,const string &Dir = getCurrentPath());
Physical_file(const string &FileName, const string &Type, const string &Dir = getCurrentPath());
~Physical_file(void);
};
}
나는이 질문에 관련이없는 생각, 좀 더 코드가 있습니다.
나는 코드를 컴파일 할 때, 나는 다음과 같은 오류 얻을 : '
Error 5 error C2664: 'FMS_Physical::Physical_file::Physical_file(const FMS_Physical::Physical_file &)' : cannot convert parameter 1 from 'const std::string' to 'const FMS_Physical::Physical_file &'
내가 (Test.cpp에있는) 생성자 오류가 사라의 정의에서 optional
을 삭제,하지만 난 돈을 선택적 매개 변수를 가져 오지 마십시오.
VS2010, python27 및 C++ 부스트 라이브러리를 사용하여 컴파일 중입니다.
왜이 오류가 발생하는지 설명 할 수 있습니까? 어떻게 해결할 수 있습니까?
편집 내가 대신 다음 줄을 사용하여 세 번째 생성자를 노출 시도
는 :
.def(init<const string&, const string &, optional<const string &>>())
이 오류가 발생하지 않았다.
몇 줄이 생길 때까지 깨진 코드를 계속 끓여야한다고 생각합니다. 문제를 명확히하는 데 도움이 될 것입니다. –