我想学习在Lazarus中开发应用程序,但我需要Lazarus的资源,最好是书籍.
请记住,我知道Pascal的0.谢谢.
假设我有"Form1"和"Form2",两者都是表格.在Form1中有Main Class和Main方法.
在Form1中,我创建了一个对象,如:
public myobject ob1 = new myobject();
Run Code Online (Sandbox Code Playgroud)
但是,在Form2中,我有这个代码:
private void bdCancelar_Click(object sender, EventArgs e)
{
ob1.status = 1; // I can't access ob1 !!!
}
Run Code Online (Sandbox Code Playgroud)
有帮助吗?
谢谢.
给出以下示例代码:
#include <memory>
class Foo {
public:
Foo(std::shared_ptr<int> p);
private:
std::shared_ptr<int> ptr;
};
Foo::Foo(std::shared_ptr<int> p) : ptr(std::move(p)) {
}
class Bar {
public:
Bar(int &p);
private:
std::shared_ptr<int> ptr;
};
Bar::Bar(int &p) : ptr(std::make_shared<int>(p)) {
}
int main() {
Foo foo(std::make_shared<int>(int(256)));
Bar bar(*new int(512));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
Foo和Bar都能正常工作.但是,在调用构造函数时创建shared_ptr然后使用std :: move传递所有权并仅传递对象的引用并将shared_ptr的创建委托给类构造函数之间是否存在任何差异?
我假设第二种方式更好,因为我不必移动指针.但是,我大多数时候都看到了我正在阅读的代码中使用的第一种方式.
我应该使用哪一个?为什么?
可能重复:
如何将单个char转换为int
好吧,我正在做一个基本的程序,它处理一些输入,如:
2 + 2
所以,我需要添加2 + 2.
我做了类似的事情:
string mys "2+2";
fir = mys[0];
sec = mys[2];
Run Code Online (Sandbox Code Playgroud)
但现在我想将"fir"添加到"sec",所以我需要将它们转换为Int.我试过"int(fir)"但没有奏效.