作者:手机用户2502898783 | 来源:互联网 | 2023-06-08 11:45
IhaveasituaioninwhichIwanttodeclareaclassmemberfunctionreturningatypethatdependso
I have a situaion in which I want to declare a class member function returning a type that depends on the class itself. Let me give you an example:
我有一个情境,我想声明一个类成员函数返回一个依赖于类本身的类型。让我给你举个例子:
class Substring {
private:
string the_substring_;
public:
// (...)
static SubstringTree getAllSubstring(string main_string, int min_size);
};
And SubstringTree is defined as follows:
而SubstringTree的定义如下:
typedef set SubstringTree;
My problem is that if I put the SubstringTree definition after the Substring definition, the static method says it doesn't know SubstringTree. If I reverse the declarations, then the typedef says it doesn't know Substring.
我的问题是如果我在Substring定义之后放置SubstringTree定义,静态方法说它不知道SubstringTree。如果我反转声明,那么typedef表示它不知道Substring。
How can I do it? Thanks in advance.
我该怎么做?提前致谢。
4 个解决方案