具有两个文件的转发类型声明 [英] Forward type declaration with two files

查看:148
本文介绍了具有两个文件的转发类型声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文件.

文件1:

namespace A

type A1() = 
   // ....

文件2:

namespace A

type A2() = 
   // ....

我可以在文件2中使用A1和A2类型,但在文件1中只能看到A1.我认为这是因为编译器在解析文件1时并不了解A2.

I can use A1 and A2 types in File 2, but I can see only A1 in File 1. I think it is because compiler don't know about A2 when it is parsing File 1.

在这种情况下,有什么方法可以进行类似正向类型的声明吗?或更改编译器解析源文件的顺序.对我来说,在File1中拥有A1和A2就足够了,而在File1中只有A2.

Is there any way to make something like forward type declaration in this case ? Or to change the order of parsing the source files by compiler. It will be enough for me to have A1 and A2 in File1, and only A2 in File1.

更新:

我相信这不是这个问题的副本.我知道类型声明中的and关键字,但是我无法将两个不同的文件合并为一个(请参阅问题标题).

I believe it is not dublicate of this question. I know about and keyword in the type declaration, but I can not merge two different files in one (See question title).

推荐答案

更改解析源文件的顺序

change the order of parsing the source files

这可以通过更改Visual Studio中文件的顺序来完成:分别单击鼠标右键和Move Up Move Down

This can be done by changing the order of the files in Visual Studio: right-click and Move Up respectively Move Down

这篇关于具有两个文件的转发类型声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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