C++新手; 基本了解包含,库和编译过程.做了几个简单的makefile.
我当前的项目涉及使用informix DB api,我需要在多个非标准目录中包含头文件.怎么写呢?没有在网上找到任何东西,可能是因为我没有使用好的搜索条件
这是我试过的一种方式(不工作).只是为了显示makefile
LIB=-L/usr/informix/lib/c++
INC=-I/usr/informix/incl/c++ /opt/informix/incl/public
default: main
main: test.cpp
gcc -Wall $(LIB) $(INC) -c test.cpp
#gcc -Wall $(LIB) $(INC) -I/opt/informix/incl/public -c test.cpp
clean:
rm -r test.o make.out
Run Code Online (Sandbox Code Playgroud) 有什么区别
int * num = new (int);
Run Code Online (Sandbox Code Playgroud)
和
int * num = new int;
Run Code Online (Sandbox Code Playgroud)
?
有什么不同吗?
编辑 thx all.......哪一个是最正确的答案?
我只想写(追加)到日志文件.我在这里查了一下:http:
//www.cplusplus.com/reference/iostream/fstream/open/
所以这就是我所做的
#include <fstream>
fstream outfile;
//outfile.open("/tmp/debug.txt" ); // works, simply for writing
outfile.open("/tmp/debug.txt", fstream::app ); // does nothing
outfile << "START" << endl;
outfile.close();
Run Code Online (Sandbox Code Playgroud) gsoap及其工具wsdl2h和soapcpp2为我提供了一个包含以下内容的soapStub.h文件:
class SOAP_CMAC ns2__SOAPKunden
{
public:
std::string *adresszusatz;
// ...
public:
virtual int soap_type() const { return 7; }
// ...
ns2__SOAPKunden() : adresszusatz(NULL), x(NULL) { } // left out all member init.
virtual ~ns2__SOAPKunden() { }
};
Run Code Online (Sandbox Code Playgroud)
我从一个小应用程序开始,使用该类用informix DB中的数据填充对象.
但要成功编译我必须放弃所有的虚拟东西 - 我发现很多关于这个错误的帖子和在子类中使用虚拟成员 - 否则我得到
main.o: In function `ns2__SOAPKunden::ns2__SOAPKunden()':
main.cpp:(.text._ZN15ns2__SOAPKundenC1Ev[ns2__SOAPKunden::ns2__SOAPKunden()]+0xf): undefined reference to `vtable for ns2__SOAPKunden'
main.o: In function `ns2__SOAPKunden::~ns2__SOAPKunden()':
main.cpp:(.text._ZN15ns2__SOAPKundenD1Ev[ns2__SOAPKunden::~ns2__SOAPKunden()]+0x13): undefined reference to `vtable for ns2__SOAPKunden'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我承认经过多年的脚本编写后,我很难理解C++代码......我想问一下下一步要做什么的建议.我的班级没有派生类,例如让我惊讶的是什么.
我使用blender 2.6并添加一个文本对象
bpy.ops.object.text_add(location=(x,y,z))
Run Code Online (Sandbox Code Playgroud)
而只是想设置文本,无法弄清楚.我在python控制台中找到了我能做到的
bpy.data.texts['Text.001'].write("my text")
Run Code Online (Sandbox Code Playgroud)
但(一般情况下)我很困惑如何引用最后创建的对象来执行某些操作.在教程中有一些primitive_MESHTYPE_add快捷方式,它们不是返回创建的对象.你能告诉我怎么做Text.new()吗?
两者之间是否存在有效差异?
<style type="text/css">@import url(/css/layout.css) all;</style>
Run Code Online (Sandbox Code Playgroud)
和
<link href="/css/layout.css" type="text/css" static="all" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud)
浏览器的行为有何不同?
从w3c等推荐什么?
如果我在运行时计算名称,如何按名称访问对象的属性?
例如.我遍历键并想要获取属性的每个值"field_" . $key.
在python中有getattribute(myobject, attrname).
当然,它有效,eval("$val=$myobject->".$myattr.";");
但IMO这很难看 - 有更清洁的方法吗?
在我的家庭包装盒上,bundle install命令确实要求输入密码并在其中安装宝石
/var/lib/gems/1.8/gems / ...
但在办公室中,它们安装在我的〜/ .bundler / cache / git中,或至少缓存在这里,而未安装在主文件系统中
我不知道如何设置它们的安装路径。请帮助!
我使用简单的bool指针类成员.分配错误的分配.true表现不同 - 请参阅代码中的注释.我在下面测试另一个.
我用编译器调用 g++ -o basic basic.cpp
class Test
{
public:
int a;
bool* abool;
};
int main() {
Test t;
//t.abool = false; // WORKS
//t.abool = true; // ERROR: cannot convert 'bool' to 'bool*' in assignment - expected IMO;
// this should work for both values IMO
//*(t.abool) = true; // Segmentation fault
//*(t.abool) = false; // Segmentation fault
cout << t.abool << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个自定义导入和导出,目前作为外部脚本(通过bootstrap),我打算以更通用的方式创建一个模块.
我正在为nagios和我们的主机管理和nagios配置btw构建一个前端.也许它可能对其他环境有用(网络管理)
现在我需要知道如何获取x类型的所有节点的列表?
我想避免直接SQL.
我得到的一个建议是制作一个rs并解析它,但是我接受了drupal db十几次来提取各种节点,所以对一件事做一个Web请求感觉很奇怪
所以我正在寻找的新手drupal dev只是指向这个任务的基本搜索模块api的指针
TIA florian