非mumber函数可以多次delcared,而成员函数只能声明一次?这是正确的吗 ?我的例子似乎说是的.
但为什么 ?
class Base{
public:
int foo(int i);
//int foo(int i=10); //error C2535: 'void Base::foo(int)' : member function already defined or declared
};
//but it seems ok to declare it multiple times
int foo(int i);
int foo(int i=10);
int foo(int i)
{
return i;
}
int main (void)
{
int i = foo();//i is 10
}
Run Code Online (Sandbox Code Playgroud) 我知道在C++中未指定函数参数的评估顺序,见下文,
//简单明显的一个.
callFunc(getA(),getB());
Run Code Online (Sandbox Code Playgroud)
可以相当于:
int a = getA();
int b = getB();
callFunc(a,b);
Or this:
int b = getB();
int a = getA();
callFunc(a,b);
Run Code Online (Sandbox Code Playgroud)
这是完美的,我认为大多数人都知道这一点.
但我已经尝试过VC10,gcc 4.72并且他们都首先评估b(从右到左),这意味着b首先被推入堆栈帧然后a.
我只是想知道哪个c ++编译器应该尝试使上面的代码首先评估?所以在b之前被推到了堆栈.
谢谢
我们都知道我们可以使用dumpbin for .obj文件来显示所有符号,包括外部符号.
dumpbin /symbols ExternCTest.ob
00F 00000000 UNDEF notype () External | ?foo@@YAHH@Z (int __cdecl foo(int))
Run Code Online (Sandbox Code Playgroud)
但我想知道我怎么能为DLL做这个?我也尝试过dumpbin/exports以及依赖walker,但它没有显示外部符号.
我该怎么办?
谢谢
我使用以下示例使用VS2008测试IEEE 754浮动格式:
int main(int argc, char *argv[])
{
float i = 0.15625;
}
Run Code Online (Sandbox Code Playgroud)
我把&i放到VS2008手表上,我看到地址是0x0012FF60,我可以从内存调试窗口看到地址的内容是00 00 20 3e,见下图:
0x0012FF60 00 00 20 3e cc cc cc cc
BTW我有IEEE754浮动格式的基本知识,我知道IEEE 754浮动格式由三个字段组成:符号位,指数和分数.分数是没有最重要位的有效数.
但是我如何从小端00 00 20 3e到0.15625精确计算?
非常感谢
c ++/boost使用都知道我们可以轻松地重置一个指向新实例的智能指针(旧的实例同时销毁).我想知道我们如何为COM智能指针做到这一点?
_COM_SMARTPTR_TYPEDEF(IMyClass,__ uuidof(IMyClass));
//normal class A
class A{
IMyClass m_spIMyClassObj; //this COM smart pointer is a member variable of a normal class
};
Run Code Online (Sandbox Code Playgroud)
我初始化COM智能指针:
m_spIMyClassObj.CreateInstance(__uuidof(MyLib::IMyClass));
Run Code Online (Sandbox Code Playgroud)
这很好但是在A的生命周期中,我需要将COM智能指针m_spIMyClassObj重置为一个新的IMyClass实例,我该怎么做(还要确保清除旧的id).
谢谢