Visual Studio C++ 2008/2010是否_mm_malloc正式支持?它已定义,malloc.h但我无法在MSDN库中找到它的描述.
我第一次使用dot + GraphViz来帮助规划图表数据库架构.
随着我添加更多节点,输出看起来不太理想.特别是,语言和国家看起来相当混乱.
我已经尝试了一些基本的排名,但却无法影响它.
我怎样才能获得更清晰的输出?
代码:
digraph ReferenceGraph {
nodesep = 2;
edge [color=gray50, fontname=Calibri, fontsize=11]
node [shape=record, fontname=Calibri, fontsize=11]
root [label="Reference Node", color=darkgreen, fontcolor=darkgreen, fontname=Calibri, fontsize=11]
sue [label="{{User}|{GivenName=Sue}|{FamilyName=Williams}|{Username=swilliams}|{EmailAddress=Sue.Williams@foo.com}|{BusinessPhone=02 1234 5678}|{MobilePhone=0414 123 456}|{PasswordSalt=fcd376dc}|{PasswordHash=a8635cfd2930ebc0cc78}|{PreviousPasswordSalt=gggf6dc}|{PreviousPasswordHash=wer435cfd2930ebc0cc78}|{RequirePasswordChangeOnNextLogin=true}|FailedLoginAttempts=0|LastLoginAttemptUtc=21 Jun 2011 16:43:01 UTC|{DateCreatedUtc=20 Jun 2011 15:43:07 UTC}}", color=blue, fontcolor=blue]
sue -> root [label="ADMINISTERS"]
clint [label="{{Client}|{UniqueId=100}|{GivenName=Clint}|{MiddleNames=ian bill}|{FamilyName=Wood}|{PreferredName=Woods}|{Gender=Male Female Unknown}|{PlaceOfBirthTown}|{PlaceOfBirthState}|{PlaceOfBirthCountry}|{Email=clint.wood@foo.com}|{LanguageComments}|{InterpreterRequired=true false}|{InterpreterComments}|{Religion=Buddhist}|{LegalOrders=order1}|{DateOfBirth=21 June 1979}|{DateOfBirthCertainty=Confirmed Unconfirmed Estimated}}", color=blue, fontcolor=blue]
clint -> acme [label="CLIENT_BELONGS_TO"]
clint -> english [label ="SPEAKS"]
cat [label="Cat (Client)"]
cat -> acme [label="CLIENT_BELONGS_TO"]
cat -> english [label …Run Code Online (Sandbox Code Playgroud) 我们都知道Boost.
还有哪些其他免费的C++库值得使用?为什么?它们是否可以与常见的编译器一起使用?
指向const的指针和函数的常用指针之间有什么区别吗?什么时候使用const限定符适合独立函数?
我写了一些简短的样本来说明我的问题:
#include <iostream>
using namespace std;
int sum( int x, int y ) { return x + y; }
typedef int sum_func( int, int );
int main()
{
const sum_func* sum_func_cptr = ∑ // const function
sum_func* sum_func_ptr = ∑ // non-const function ?
// What is the difference between sum_func_cptr and sum_func_ptr
int x = sum_func_cptr( 2, 2 );
cout << x << endl;
int y = sum_func_ptr( 2, 2 );
cout << y << endl;
sum_func_cptr = …Run Code Online (Sandbox Code Playgroud) 我是STL的新手.关于使用地图存储任意对象的事情让我很难过:
std::map<MyClassObj, MyDataObject> MyMap;
Run Code Online (Sandbox Code Playgroud)
是我如何找到对象.MyMap.find(MyClassObjInstance)如何工作?我是否需要实现自己的迭代器并提供一些标准函数,其中包括一些等价函数?任何例子将不胜感激.
是否有另一种方法来使用标准库存储任意对象的关联列表?我已经在使用stl来维护平台的可移植性,并且不希望像BOOST那样添加另一个库依赖项.
只要有一台显示器插入系统,我就需要从Windows获得某种事件.Windows中是否有任何API可以做到这一点.顺便说一下,它是一个C++应用程序
如果我想创建一个指向struct的智能指针,我会这样做:
struct A
{
int value;
};
typedef boost::shared_ptr<A> A_Ptr;
Run Code Online (Sandbox Code Playgroud)
所以,我可以写下面的内容:
A_Ptr pA0(new A);
pA0->value = 123;
Run Code Online (Sandbox Code Playgroud)
但是,如果我有这样的模板结构:
template<typename T>
struct B
{
T value;
};
Run Code Online (Sandbox Code Playgroud)
我想写下面的内容:
B_Ptr<char> pB0(new B<char>);
pB0->value = 'w';
Run Code Online (Sandbox Code Playgroud)
那么,我该如何申报B_Ptr?
学习C++,发现了功能模板.本章提到了模板专业化.
template <> void foo<int>(int);
void foo( int );
为什么专注于你可以使用第二个?我认为模板可以概括.当你可以使用常规函数时,为特定数据类型专门化一个函数有什么意义?
显然,模板专业化存在是有原因的.什么时候应该使用?我读过Sutter的"为什么不专攻......"一文,但我需要更多的外行人版本,因为我只是在学习这些东西.
请考虑以下代码:
class B
{
int x;
public:
B() : x( 10 ) {}
int get_x() const { return x; }
void set_x( int value ) { x = value; }
};
class A
{
boost::shared_ptr<B> b_;
public:
boost::shared_ptr<B> get_b() const { return b_; } // (1)
};
void f( const A& a)
{
boost::shared_ptr<B> b = a.get_b();
int x = b->get_x();
b->set_x( ++x ); // (2)
}
int main()
{
A a;
f( a );
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在这段代码中,(2)独立编译没有任何错误或警告,这get_b …