相关疑难解决方法(0)

C中的面向对象

什么是一组漂亮的预处理器黑客(ANSI C89/ISO C90兼容),它在C中实现某种丑陋(但可用)的面向对象?

我熟悉一些不同的面向对象语言,所以请不要回答"学习C++!"这样的答案.我读过" 面向对象的ANSI C编程 "(当心:PDF格式)和其他一些有趣的解决方案,但我最感兴趣的是你:-)!


另请参见您能用C编写面向对象的代码吗?

c oop object

152
推荐指数
9
解决办法
7万
查看次数

正确的C库代码命名约定

命名作为基于C的代码库/ API的一部分的文件和函数的正确方法是什么?

c standards naming naming-conventions

5
推荐指数
1
解决办法
1382
查看次数

在C中使用范围

经过长时间的停顿后,我再次被迫使用C EDIT(版本C89).真正令人不安的是,开头的变量声明违反了这个C++编码规则.客户的功能很庞大,每个功能开头的变量列表几乎无法管理.可以使用范围来解决这个问题吗?它是合适的还是"黑客"?

第一个案例.代替:

{//Beginning of the function
    int i;
    int Important=0;
Run Code Online (Sandbox Code Playgroud)

使用:

 {//Beginning of the function
    int Important=0;
    //... code
    { int i; for (i=0,... } //use i in close scope
Run Code Online (Sandbox Code Playgroud)

第二种情况:

{//Beginning of the function
    int i;
    // many other var definitions
    if ( !initialized ) return;
Run Code Online (Sandbox Code Playgroud)

使用:

{//Beginning of the function
    {if ( !initialized ) return; ... other checks}
    int i;
    // many other var definitions
Run Code Online (Sandbox Code Playgroud)

c scope

2
推荐指数
1
解决办法
123
查看次数

标签 统计

c ×3

naming ×1

naming-conventions ×1

object ×1

oop ×1

scope ×1

standards ×1