进行模块化和参数化编码 [英] Do Modular and parameterise coding

查看:122
本文介绍了进行模块化和参数化编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!!

我想进行模块化和参数化编码,其中所有变量,文件指针,设备句柄都在一个函数中初始化并在另一个函数中释放,我不知道它是怎么回事?请为我提供更好的代码和解决方案性能的解决方案。

先谢谢!

Hi!!
I want to modular & parametrise coding in which all variables,file pointers,device handles are initialise in one function & release in another function,I don''t get idea about it!!How does that?Please suggest me solution for better performance of code & solution.
Thanks in Advance!

推荐答案

在C ++中您可以使用 RAII [ ^ ]。在构造函数中进行初始化,在析构函数中进行一些清理。在析构函数中特别注意异常。



在C中你必须告诉客户你的代码遵循协议:首先调用一些发明的初始化(...)函数,最后发现了一些 Release(...)函数。这两个功能都是你的图书馆的一部分,并在你的问题中做你需要的。

干杯

Andi
In C++ you may use RAII[^]. Do initialization in the constructor, do some cleanup in the destructor. Take special care of exceptions in the destructor.

In C you must tell the client of your code to follow the protocol: call first some invented Init(...) function, then at the end some invented Release(...) function. Both functions are part of your library and do what you require in your question.
Cheers
Andi


这篇关于进行模块化和参数化编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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