在另一个文件中创建函数并从多种形式访问? [英] Create functions in another file and access from multiple forms?

查看:80
本文介绍了在另一个文件中创建函数并从多种形式访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个函数,希望可以通过不同的形式进行访问,我想知道是否可以将它们放在某种类型的文件中并调用它们?我尝试了一个类文件,但效果不是很好.我认为这应该是可能的 因为您可以在C中完成此操作,但那都是基于非GUI的东西.

I have a couple functions that I want to be accessible from different forms and I am wondering if it is possible to put these in a file of some type and call them? I tried with a class file and it did not work out so well. I figure this should be possible since you can do it in C but then that was all nongui based stuff.

推荐答案

当这些是静态函数时,请将其放入静态类中.否则,可能适合一个合适的单身人士.但这取决于您的功能"的实际性质.同样,干净设计的类层次结构可能是一个解决方案...
When these are static functions, then put it into a static class. Otherwise, the may fit into an appropriate singleton. But this depends on the actual nature of your "functions". Also an clean designed class hierarchy may be a solution...


这篇关于在另一个文件中创建函数并从多种形式访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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