嵌套名称规范中的不完整类型名称
incomplete type name in nested name specifier
我有以下两个类,我想将第二类的方法之一指定为第一个朋友,以便该方法可以访问其变量。我在标题中尝试了以下内容:
class SequenceThreader;
enum MappingDirection {Nowhere, Forward, Backwards};
class SequenceMapping {
friend void SequenceThreader::query_paths_to_fasta(std::ofstream& output_file) const;
private:
seqID_t seq_id;
int32_t first_seq_pos;
int32_t last_seq_pos;
sgNodeID_t node;
int32_t first_node_pos;
int32_t last_node_pos;
int32_t matched_unique_kmers;
uint64_t possible_unique_matches;
uint64_t n_kmers_in_node;
bool direction_will_continue(int32_t next_position) const;
public:
SequenceMapping();
bool operator==(const SequenceMapping &other);
bool operator<(const SequenceMapping &other) const;
friend std::ostream& operator<<(std::ostream& stream, const SequenceMapping& sm);
void initiate_mapping(uint64_t sequence_id);
bool ismatched();
void start_new_mapping(const graphPosition& gpos, int32_t seqpos, const UniqueKmerIndex& counts);
void extend(int32_t nodepos, int32_t seqpos);
sgNodeID_t absnode() const;
sgNodeID_t dirnode() const;
int32_t n_unique_matches() const;
MappingDirection node_direction() const;
MappingDirection seq_direction() const;
bool mapping_continues(const graphPosition& gpos) const;
double POPUKM() const;
};
class SequenceThreader {
typedef std::unordered_map<seqID_t, std::vector<SequenceMapping>> SequenceMappingStore;
typedef std::unordered_map<seqID_t, std::vector<std::vector<SequenceMapping>>> SequenceMappingPathsStore;
private:
SequenceGraph& sg;
UniqueKmerIndex graph_kmer_index;
uint8_t k;
std::string query_seq_file;
std::string output_prefix;
uint64_t memory_limit;
SequenceMappingStore mappings_of_sequence;
SequenceMappingPathsStore paths_of_mappings_of_sequence;
void map_sequences_from_file(uint64_t min_matches, const std::string& filename);
std::set<SequenceGraphPath> all_unique_paths() const;
void print_mapping_path_name(const std::vector<SequenceMapping>& path, std::ofstream& output_file) const;
public:
explicit SequenceThreader(SequenceGraph &_sg, uint8_t _k = 31) : sg(_sg), k(_k), graph_kmer_index(sg, _k) {}
void map_sequences(uint64_t min_matches, const std::string& filename, const std::string& output) {
output_prefix = output;
query_seq_file = filename;
map_sequences_from_file(min_matches, filename);
}
void print_mappings() const;
void mappings_paths();
void print_paths() const;
void graph_paths_to_fasta(std::ofstream& output_file) const;
void query_paths_to_fasta(std::ofstream& output_file) const;
void print_unique_paths_sizes(std::ofstream& output_file) const;
};
但是我遇到了一个编译错误:
In file included from /Users/bward/github/bsg/src/sglib/SequenceThreader.cpp:8:
/Users/bward/github/bsg/src/sglib/SequenceThreader.h:22:17: error: incomplete type 'SequenceThreader' named in nested name specifier
friend void SequenceThreader::query_paths_to_fasta(std::ofstream& output_file) const;
让我陷入困境,因为朋友声明文档在这里:http://en.cppreference.com/w/cpp/language/frirds
说类似 friend char* X::foo(int); // members of other classes can be friends too
的话很好。
我需要做什么才能使它编译?
SequenceThreader
必须首先定义,只有向前声明是不够的。正如错误消息所说的SequenceThreader
需要在此处完成类型,否则编译器将不知道SequenceThreader
具有该命名query_paths_to_fasta
的成员。
要解决问题,您可以将SequenceThreader
的定义提前移动(并删除前向声明(。
相关文章:
- 特征::矩阵<双精度,1,3> 结构类型函数中的返回类型函数
- 从类型列表中递归删除重复项会导致编译器堆空间错误 (VS2017)
- 测试两个类型列表中的所有组合
- 类型名称 T::类型::值中的预期非限定 id
- 矢量类型规范中的星号用于什么?
- 在自定义类型图中重用 SWIG 映射
- 基类类型向量中的派生结构
- 从自定义数据类型向量中删除重复元素
- std::begin-类型特征中未考虑用户定义的重载
- 将函数应用于元组中的每个元素,将每个元素强制转换为类型包中的不同类型,然后作为参数包传递
- 初始化在类类型 #define 中定义的非静态成员数组,不带默认 ctor
- 运行时错误:有符号整数溢出:964632435 * 10 无法在类型 'int' 中表示
- 为什么在VS2015中模板相关的嵌套类型名称中不需要typename关键字?
- 将子类实例保存在父类型变量中并通过父变量使用 Child 函数?
- C++:从类型索引中获取超类类型索引
- 了解元函数以在类型包中查找类型
- 为什么删除此类型别名中的 const 限定符?
- 不能在类型说明符中定义联合
- 从模板实例化/类型推断中查找错误消息的实际来源
- 如何使用CIN将输入整数值获取到char类型变量中