小编Ita*_*ham的帖子

Fprintf VS _ftprintf

两者都有几乎相同的输入参数:

int _ftprintf( FILE *stream, const _tchar *format [, argument ]...)

int fprintf(FILE *stream, const char *format, ...)
Run Code Online (Sandbox Code Playgroud)

这两种格式参数有什么区别?我应该什么时候使用它们?

c printf filestream

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

转换为派生类的ptr到ptr

如果我没有为Base**指定显式强制转换,为什么会出现编译错误?

处理派生类时,我可以使用指针指针吗?

class Base { };
class Child : public Base { };

void SomeFunction(Base** ppoObj) {}
void SomeFunction(Base* poObj) {}

int main()
{   
    Child *c = new Child();

    // This passed.
    SomeFunction(c);
    SomeFunction((Base**)&c);

    // CompilationError
    SomeFunction(&c);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ inheritance pointers casting

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

嵌套类型:struct vs class

我应该何时在类中的结构中定义成员,何时应该在嵌套类中定义成员?

例如:

class SkypeProtocol
{
public:
    SkypeProtocol();
    virtual ~SkypeProtocol(){}

private:

    class SkypeProtocolDateTime
    {
    private:
        UI32 uDate;
        ERROR GetDateString(PUCHAR pcBuffer,PUI32 uBufLen);
    };

};
Run Code Online (Sandbox Code Playgroud)

要么

class SkypeProtocol
{
private:
    SkypeProtocol();
    virtual ~SkypeProtocol(){}

    typedef struct SkypeProtocolDateTime
    {
    private:
        UI32 uDate;
        ERROR GetDateString(PUCHAR pcBuffer,PUI32 uBufLen);
    }SSKYPE_STRUCT;

};
Run Code Online (Sandbox Code Playgroud)

c++ inner-classes c++11

0
推荐指数
1
解决办法
454
查看次数

标签 统计

c++ ×2

c ×1

c++11 ×1

casting ×1

filestream ×1

inheritance ×1

inner-classes ×1

pointers ×1

printf ×1