C++ hdf5组在C和x2B中打开+;
我只是想从hdf数据库中打开一个组。我将组名保留在字符串变量中,但是C++编译器给出以下错误。我想坚持使用字符串,因为我这样做在C++中。有什么解决办法吗?多谢各位 Reader.cpp:在构造函数“Reader::Reader(std::string)”中: Reader.cpp:5:错误:无法将参数“2”的“std::string”转换为“const char*”转换为“hid_t H5Gopen2(hid_t,const char*,hid_t)” 阅读器.hC++ hdf5组在C和x2B中打开+;,c++,hdf5,C++,Hdf5,我只是想从hdf数据库中打开一个组。我将组名保留在字符串变量中,但是C++编译器给出以下错误。我想坚持使用字符串,因为我这样做在C++中。有什么解决办法吗?多谢各位 Reader.cpp:在构造函数“Reader::Reader(std::string)”中: Reader.cpp:5:错误:无法将参数“2”的“std::string”转换为“const char*”转换为“hid_t H5Gopen2(hid_t,const char*,hid_t)” 阅读器.h ifndef READER_
ifndef READER_H
#define READER_H
#include <string>
#include "H5Cpp.h"
#define FILEHDF "/media/data/back_up.h5"
class Reader
{
private:
hid_t file_id, dataset_id, dataspace_id, group_id,strtype, memtype;
hsize_t dims[1];
herr_t status;
std::string m_fasta;
Reader() {}
public:
Reader(std::string prot_name);
void SetFasta(std::string fasta);
std::string GetFasta() {return m_fasta;}
};
#endif
main.cpp
#include <iostream>
using namespace std;
#include <string>
#include "Reader.h"
#include "H5Cpp.h"
int main()
{ std::string prot_name, fasta_seq;
prot_name="102LA";
Reader rd(prot_name);
fasta_seq=rd.GetFasta();
cout<<fasta_seq;
return 0;
}
#包括
使用名称空间std;
#包括
#包括“Reader.h”
#包括“H5Cpp.h”
int main()
{std::string prot_name,fasta_seq;
prot_name=“102LA”;
读卡器rd(保护名称);
fasta_seq=rd.GetFasta();
我想这个错误很明显。你真的读过吗?H5Gopen2(file_id,prot_name.c_str(),H5P_DEFAULT);
类似的,你试过它的建议吗?const char*c=prot_name.c_str()
#include <iostream>
using namespace std;
#include <string>
#include "Reader.h"
#include "H5Cpp.h"
int main()
{ std::string prot_name, fasta_seq;
prot_name="102LA";
Reader rd(prot_name);
fasta_seq=rd.GetFasta();
cout<<fasta_seq;
return 0;
}