假设我有一个带函数指针的函数:
int funct(double (*f)(double));
Run Code Online (Sandbox Code Playgroud)
我传给它一个实际上没有做任何事情的函数:
double g(double a) { return 1.0;}
//...
funct(g);
Run Code Online (Sandbox Code Playgroud)
编译器会优化调用g吗?或者这还有开销吗?如果确实有开销,多少钱?足够值得重载函数来接收函数指针和常量值吗?
在VC++中,我使用EnumWindows(...),GetWindow(...)和GetWindowLong()来获取窗口列表并检查窗口是否是顶部窗口(没有其他窗口作为所有者),以及窗口是否是可见的(WS_VISIBLE).然而,虽然我的桌面只显示了5个窗口,但这个EnumWindows给了我50个窗口,多么有趣!任何Windows极客都请帮我澄清一下......
我在下面写了一个函数:
void trans(double x,double y,double theta,double m,double n)
{
m=cos(theta)*x+sin(theta)*y;
n=-sin(theta)*x+cos(theta)*y;
}
Run Code Online (Sandbox Code Playgroud)
如果我在同一个文件中调用它们
trans(center_x,center_y,angle,xc,yc);
Run Code Online (Sandbox Code Playgroud)
会的价值xc和yc改变?如果没有,我该怎么办?
我将参数值传递 '*1.dat'给FindFirst,仍然是FindFirst()例程返回的第一个文件46checks5.dat,非常一致.
这是一个已知的问题吗?
vpath:=trim(vpath);
result:=true;
try
res:=findfirst(vpath+'\'+vmask,faarchive,search); //vmask = *1.dat
try
while res=0 do
begin
vlist.add(search.name); //searchname returned is 46checks5.dat!!!
res:=findnext(search);
end;
finally
findclose(search);
end;
except
result:=false;
end;
Run Code Online (Sandbox Code Playgroud) 我正在编写一个DLL,它在特定窗口上进行一些操作,但有时传递的句柄无效.是否存在任何函数来验证传递的句柄是否有效(属于窗口)?
我想知道如何计算Delphi中函数的消耗时间.
然后我想显示使用的时间并将其与另一个函数或组件进行比较,以便了解更快的函数.
我想知道Mac OS X,Windows和Linux上的编译器如何知道在哪里可以找到C头文件.
具体来说,我想知道它是如何知道在哪里找到#include <>括号.
#include "/Users/Brock/Desktop/Myfile.h" // absolute reference
#include <stdio.h> // system relative reference?
Run Code Online (Sandbox Code Playgroud)
我假设它咨询的系统上有一个文本文件.它如何知道在哪里寻找标题?是否可以修改此文件,如果是这样,该文件驻留在操作系统上的哪个位置?
似乎每次我向向量m_test添加一个对象时,都会调用析构函数方法.我错过了什么吗?我怎样才能防止这种情况发生?
class TEST
{
public:
TEST();
~TEST();
int * x;
};
TEST::TEST()
{
}
TEST::~TEST()
{
... it is called every time I push_back something to the vector ...
delete x;
}
vector<TEST> m_test;
for (unsigned int i=0; i<5; i++)
{
m_test.push_back(TEST());
}
Run Code Online (Sandbox Code Playgroud) 考虑:
{$R+}
i:= 1;
While i > 0 do
i:= i + 1;
ShowMessage(IntToStr(i));
Run Code Online (Sandbox Code Playgroud)
如果我声明i为Byte,Word,Shortint或TinyInt,我会得到范围检查错误,如预期的那样.如果我声明i为LongWord,Cardinal,Integer,LongInt或Int64,它只是通过while循环并显示负值或0值,i当你通过上限时得到.
Delphi 7不支持32位和64位数字的范围检查吗?
如何停用Delphi的"超出行尾的光标"功能?当我单击一行右侧的空白区域时,或者当我使用箭头键导航到一行时,我希望光标位于该行的实际末尾,而不是"虚拟空间".
c++ ×5
delphi ×5
c++builder ×1
delphi-xe3 ×1
findfirst ×1
function ×1
header-files ×1
ide ×1
include ×1
optimization ×1
stl ×1
styles ×1
time ×1
vector ×1
visual-c++ ×1
winapi ×1
windows ×1