如何在dlang中的类中编写前向声明 [英] How do I write a forward declaration in a class in dlang

查看:89
本文介绍了如何在dlang中的类中编写前向声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为函数做一个前向声明,它是一个类成员。我该怎么做?



我尝试过:



我试过这段代码:

  class  TQ {
public
int a,b;
int GetA(string s);
}

int TQ.GetA(string s){
返回 .a;
}





但是id不能编译,说在第7行而不是'。'中需要分号。 ,但是分号并没有解决问题。

解决方案

你有没有尝试过这样的事情:

  class  TQ {
public
int a,b;
int GetA( string s){
返回 .a;
};
}


你不能这样做 [ ^ ]因为不需要也不允许。

I want to make a forward declaration for a function, which is a class member. How do I do this?

What I have tried:

I've tried this code:

class TQ{
public:
	int a,b;
	int GetA(string s);
}

int TQ.GetA(string s){
	return this.a;
}



But id doesn't compile, saying that a semicolon is expected in Line 7 instead of the '.', but the semicolon doesn't solve the problem.

解决方案

Did you try something like:

class TQ{
public:
    int a,b;
    int GetA(string s){
        return this.a;
    };
}


You cannot do that[^] as it isn't needed nor allowed.


这篇关于如何在dlang中的类中编写前向声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆