我想问一下boost是否有一些库可用于加密任务.
好吧如果boost没有这样的libs我想听听你推荐什么crypt库.(一些widly使用的libs)
谢谢.
我有一个双核处理器,根据解释,我只能使用2个线程,但实际上我可以同时启动2个以上的线程:
以下是解释的副本:
boost :: thread类提供的静态hardware_concurrency()方法根据底层的CPU或CPU核心数返回可以在物理上同时执行的线程数.在常用的双核机器上调用此函数,返回值2.这允许一种简单的方法来识别给定多线程应用程序应同时使用的理论最大线程数.
在我的情况下,hardware_concurrency()方法返回数字2,但是该程序同时使用4个线程:
#include <iostream>
#include <boost\thread.hpp>
using namespace std;
using boost::thread;
using namespace boost::this_thread;
using boost::posix_time::seconds;
void f1()
{
for(int i = 0; i < 10; ++i)
{
cout << i << endl;
sleep(seconds(2));
}
}
void f2()
{
for(int i = 0; i < 10; ++i)
{
cout << i << endl;
sleep(seconds(2));
}
}
int main()
{
// 4 threads are executed on dual core machine (no problem)
thread thr1(f1);
thread thr2(f2);
thread thr3(f1); …Run Code Online (Sandbox Code Playgroud) 我正在使用visual studio 2010,Qt加载项等等都可以,然后使用Qt加载项创建新项目...当在VS中双击*.ui(实际表单)文件时它打开Qtdesigner,然后我放了一些控件在,但这根本不会改变我的代码:/
Qt表单已更改它包含那些控件但源文件与之前的构建我的项目相同.
我错过了什么?我认为Qtdesinger应该为我使用Qtdesigner创建的对象添加一些代码.
没有它我们必须编写所有的代码,好像没有Qtdesigner所以Qtdesinger是Visual Studio中的useles,我们可以通过手工编写一个表单接口来做同样的事情.非常感谢.
编辑:
好的我从Qt网站上复制了这个:
您正在引用.ui文件中的对象...
Visual Studio代码模型解析器仅解析C++源代码,这意味着无法访问.ui文件中定义的窗口小部件或对象.要解决此问题,Qt Visual Studio外接程序会自动生成.ui文件中的C++代码,方法是保存文件并在其上运行uic.每次构建项目时都会执行此步骤.如果代码完成不起作用,请尝试重建项目.在更新.ui文件后代码完成完全有效之前,您可能需要等待一段时间.有关更多信息,请参阅"修改项目属性"部分.它仍然不起作用......
您应该刷新代码模型Intellisense.这是通过打开解决方案资源管理器,调用项目的上下文菜单并激活项目Update Intellisense来完成的.
现在它看起来我遇到了这样的问题,但这根本没有帮助,更新了智能.我在visual studio中看不到这样的选项,它看起来我的visual studio插件无法正常工作.
它说"你应该刷新代码模型"Woot?有人可以解释我该怎么做.
以下是构建项目时的一些输出警告:
警告1警告:'C:\ Users\Admin\documents\visual studio 2010\Projects\VisualStudio\test\test.qrc'中没有资源.C:\ Users\Admin\documents\visual studio 2010\Projects\VisualStudio\test\RCC警告2警告LNK4099:找不到PDB'vc100.pdb'与'qtmaind.lib(qtmain_win.obj)'或'C:\Users\Admin\documents\visual studio 2010\Projects\VisualStudio\vc100.pdb'; 链接对象,好像没有调试信息C:\ Users\Admin\documents\visual studio 2010\Projects\VisualStudio\test\qtmaind.lib(qtmain_win.obj)
在下面的代码中,如何为函数main中的对象A分配rvalue?
#include <iostream>
using namespace std;
class A
{
public:
int* x;
A(int arg) : x(new int(arg)) { cout << "ctor" << endl;}
A(const A& RVal) {
x = new int(*RVal.x);
cout << "copy ctor" << endl;
}
A(A&& RVal) {
this->x = new int(*RVal.x);
cout << "move ctor" << endl;
}
~A()
{
delete x;
}
};
int main()
{
A a(8);
A b = a;
A&& c = A(4); // it does not call move ctor? why?
cin.ignore(); …Run Code Online (Sandbox Code Playgroud) 好吧,我认为这段代码和程序输出可以自我解释:
#include <iostream>
#include <string>
using namespace std;
class Test
{
public:
void Not_Static(string args)
{
cout << args << endl;
}
};
int main()
{
Test* Not_An_instance = nullptr;
Not_An_instance->Not_Static("Non-static function called with no object?");
cin.ignore();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
程序输出:
没有对象调用的非静态函数?
为什么会这样?
我在 stackoverflow 上读过类似的问题,但没有一个答案能解决我的问题。
我需要使用/MDd标志进行编译,这是我的 CMake 命令:(注意粗体/MDd标志)
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:/temp -DCMAKE_C_FLAGS="-Zi -W4 -WX- -Od -Oy- -D_WIN32 -DWIN32=1 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -D_CRT_SECURE_NO_WARNINGS=1 -D_SCL_SECURE_NO_警告=1 -D_MBCS -GF- -Gm -EHsc -RTCc -RTC1 -MDd -GS -Gy- -Qpar- -fp:精确 -fp:除了 -Zc:wchar_t -Zc:forScope -GR -Gd -analyze- -errorReport :迅速的”
这是执行nmake时的输出:
Run Code Online (Sandbox Code Playgroud)cl : Command line warning D9025 : overriding '/MDd' with '/MTd' cl : Command line warning D9025 : overriding '/W4' with '/W3'
有人可以告诉我我在这里做错了什么吗?
以下是我从MSDN中复制的有关new运算符的内容:
该
new操作者不能被用于分配的功能,但它可用于指针分配给功能.下面的示例分配然后释放七个指向返回整数的函数的数组的数组.Run Code Online (Sandbox Code Playgroud)int (**p) () = new (int (*[7]) ()); delete *p;
好吧,第一行没有什么奇怪的,它为函数分配了一个指针数组,但我只是不明白第二行如何删除该数组?我认为它应该是:
delete[] *p;
Run Code Online (Sandbox Code Playgroud)
有谁能解释一下?
根据维基百科,在这个例子中:
struct Base {
virtual void some_func(float);
};
struct Derived : Base {
virtual void some_func(float) override;
};
Run Code Online (Sandbox Code Playgroud)
我认为override不是C++关键字,那它究竟意味着什么?没有那个关键字,我们可以实现同样的目标,那么为什么有人需要呢?
还有一个关键字final在VS2010上还没有用:
struct Base1 final { };
struct Derived1 : Base1 { }; // ill-formed because the class Base1
// has been marked final
Run Code Online (Sandbox Code Playgroud) 有两种情况typedef混淆了我,当谈到extern template declaration和explicit template instantiation.
为了说明这两个,请参见下面的2个示例代码片段.
考虑以下示例(案例1):
// suppose following code in some cpp file
template <typename T>
struct example
{
T value;
};
// valid typedefs
typedef example<int> int_example;
typedef example<std::string> string_example;
// explicit instantiation using above typedefs
template class int_example; // -> compile time error
template class string_example; // -> compile time error
// instead we need to use type names
template class example<int>; // -> OK
template class example<std::string>; …Run Code Online (Sandbox Code Playgroud) c++ ×8
c++11 ×2
boost ×1
build ×1
cmake ×1
compilation ×1
cryptography ×1
extern ×1
libraries ×1
msbuild ×1
new-operator ×1
qt ×1
templates ×1
typedef ×1