我在维基百科上阅读了关于"Make"的德文文章,发现了以下两行:
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<
Run Code Online (Sandbox Code Playgroud)
为什么依赖表达式被省略,为什么目标使用双重文件扩展名?
“ Inno-Setup编译器”不知道pascal数据类型“ QWord”。是否有64位等效项?
谢谢
其实我是C++的新手.我尝试了一些东西(实际上是地图容器),但是它没有按照我想象的方式工作......在发布我的代码之前,我会很快解释它.
我创建了3个类:
ClassA ClassDerivedA ClassAnotherDerivedA
最后两个来自"ClassA".
我进一步创建了一张地图:
map<string,ClassA> test_map;
Run Code Online (Sandbox Code Playgroud)
我将一些对象(来自Type ClassDerivedA和ClassAnotherDerivedA)放入地图中.请记住:映射值来自"ClassA"类型.这只会因多态性而起作用.最后,我创建了一个迭代器,它在我的地图上运行,并将用户输入与地图中的键进行比较.如果它们匹配,它将调用一个名为"printOutput"的特定方法.
还有一个问题:虽然我将"printOutput"声明为"虚拟",但是唯一被调用的方法是我的基类,但为什么呢?这是代码:
#include <iostream>
#include <map>
using namespace std;
class ClassA
{
public:
virtual void printOutput() { cout << "ClassA" << endl; }
};
class ClassDerivedA : public ClassA
{
public:
void printOutput() { cout << "ClassDerivedA" << endl; }
};
class ClassAnotherDerivedA: public ClassA
{
public:
void printOutput() { cout << "ClassAnotherDerivedA" << endl; }
};
int main()
{
ClassDerivedA class_derived_a;
ClassAnotherDerivedA class_another_a;
map<string,ClassA> test_map;
test_map.insert(pair<string,ClassA>("deriveda", class_derived_a));
test_map.insert(pair<string,ClassA>("anothera", class_another_a)); …Run Code Online (Sandbox Code Playgroud) 我希望用户在安装过程中选择许可文件,如何创建这种对话框?有谁能展示一些示例代码?
我想将String转换为字节数组,代码如下所示:
procedure StringToByteArray(const s : String; var tmp: array of Byte);
var
i : integer;
begin
For i:=1 to Length(s) do
begin
tmp[i-1] := Ord(s[i]);
end;
end;
Run Code Online (Sandbox Code Playgroud)
s [i]这里是第i个String元素(= pos i处的char),我将其数值保存到tmp.
这适用于某些角色,但并非适用于所有角色,例如:
Ord('•')返回Dec(149),这是我所期望的.
但在我的程序中,Ord(s [i])返回相同角色的Dec(8226)!
Edit1:我认为缺陷在于我的其他功能"ByteArrayToStr"
转换时......
tmp:= 149 // tmp is of type byte
Log('experiment: ' + Chr(tmp)); // prints "•"
Log('experiment2 ' + IntToStr(Ord(Chr(tmp)))); // prints 149
Run Code Online (Sandbox Code Playgroud)
......来回,这似乎有效.
但是在以下函数中使用相同的转换将不会这样做:
function ByteArrayToStr( a : array of Byte ) : String;
var
S:String;
I:integer;
begin
S:='';
For I:=0 to …Run Code Online (Sandbox Code Playgroud) 如何调用存储在向量中的对象的方法?以下代码失败...
ClassA* class_derived_a = new ClassDerivedA;
ClassA* class_another_a = new ClassAnotherDerivedA;
vector<ClassA*> test_vector;
test_vector.push_back(class_derived_a);
test_vector.push_back(class_another_a);
for (vector<ClassA*>::iterator it = test_vector.begin(); it != test_vector.end(); it++)
it->printOutput();
Run Code Online (Sandbox Code Playgroud)
该代码检索以下错误:
test3.cpp:47:错误:在 '*它.__ gnu_cxx :: __ normal_iterator <_Iterator,_container> ::操作符 - >与_Iterator = ClassA的**,_container =标准::矢量>' 请求成员 'printOutput',这是非类型'ClassA*'
问题似乎是it->printOutput();但目前我不知道如何正确调用该方法,有人知道吗?
对待米奇
inno-setup ×3
installer ×3
pascal ×3
c++ ×2
freepascal ×2
stl ×2
makefile ×1
map ×1
polymorphism ×1
vector ×1