_First, _Last, _Mid, _Next, _Dest, _Before, _After, _Begin, _End, _Left, _Right, _Idx, _Temp, _Prev,
_Count, _Distance,_Old, _New, _Val, _Found,_Result
_InIt, _OutIt, _FwdIt, _BidIt, _Ty, _Fn, _Pr.
_First, _Last, _Mid, _Next, _Dest, _Before, _After, _Begin, _End, _Left, _Right, _Idx, _Temp, _Prev,
_Count, _Distance,_Old, _New, _Val, _Found,_Result
_InIt, _OutIt, _FwdIt, _BidIt, _Ty, _Fn, _Pr.
・ class _Tr = char_traits<_E>
template<class _E,
class _Tr = char_traits<_E>,
class _A = allocator<_E> >
class basic_string {}
・ Operator overload
_Myt& operator=(const _Myt& _X){}
_Myt& operator+=(const _Myt& _X){}
・ Typename
template<class _Iter>
struct iterator_traits
{ // get traits from iterator _Iter
typedef typename _Iter::iterator_category iterator_category;
typedef typename _Iter::value_type value_type;
typedef typename _Iter::difference_type difference_type;
typedef difference_type distance_type; // retained
typedef typename _Iter::pointer pointer;
typedef typename _Iter::reference reference;
};
・ Marco
_STD_BEGIN
…
_STD_END
・ Nested class.
class _CRTIMP ios_base {
class failure : public runtime_error { … };
… …
};
・ Explicit
explicit basic_ios(_Mysb *_S)
|
|
C++中有两种"用户定义的型别转换":型别转换操作符和单参数构造函数。
explicit就是用来禁止"单参数构造函数"的型别转换功能的。
・ inline
inline ios_base& __cdecl boolalpha(ios_base& _I)
{_I.setf(ios_base::boolalpha);
return (_I); }
・ exception, failure, allocator, scentry
・ Using
Class MyRegOpen{
using std::nothrow;
}
命名空间(Namespace)
与STL相关的概念是命名空间(namespace)。STL定义在std命名空间中。有3种方法声明使用的命名空间:
1.用using关键字使用这个命名空间,在文件的顶部,但在声明的头文件下面加入:
using namespace std;
这对单个工程来说是最简单也是最好的方法,这个方法可以把你的代码限定在std命名空间中。
2.使用每一个模板前对每一个要使用的对象进行声明(就像原形化):
using std::cout;
using std::endl;
using std::flush;
using std::set;
using std::inserter;
尽管这样写有些冗长,但可以对记忆使用的函数比较有利,并且你可以容易地声明并使用其他命名空间中的成员。
3.在每一次使用std命名空间中的模版时,使用std域标识符。比如:
typedef std::vector VEC_STR;
这种方法虽然写起来比较冗长,但是是在混合使用多个命名空间时的最好方法。一些STL的狂热者一直使用这种方法,并且把不使用这种方法的人视为异类。一些人会通过这种方法建立一些宏来简化问题。
除此之外,你可以把using namespace std加入到任何域中,比如可以加入到函数的头部或一个控制循环体中。
・ Typename
・ 在c++Template中很多地方都用到了typename与class这两个关键字,而且好像可以替换,是不是这两个关键字完全一样呢?
相信学习C++的人对class这个关键字都非常明白,class用于定义类,在模板引入c++后,最初定义模板的方法为: template<class T>......
在
这里class关键字表明T是一个类型,后来为了避免class在这两个地方的使用可能给人带来混淆,所以引入了typename这个关键字,它的作用同
class一样表明后面的符号为一个类型,这样在定义模板的时候就可以使用下面的方式了: template<typename
T>......
在模板定义语法中关键字class与typename的作用完全一样。
typename难道仅仅在模板定义中起作用吗?其实不是这样,typename另外一个作用为:使用嵌套依赖类型(nested depended name),如下所示:
・ class MyArray
{
public:
typedef int LengthType;
.....
}
template<class T>
void MyMethod( T myarr )
{
typedef typename T::LengthType LengthType;
LengthType length = myarr.GetLength;
}
・
这个时候typename的作用就是告诉c++编译器,typename后面的字符串为一个类型名称,而不是成员函数或者成员变量,这个时候如果前面没有
typename,编译器没有任何办法知道T::LengthType是一个类型还是一个成员名称(静态数据成员或者静态函数),所以编译不能够通过。
Question:
1. extern template class _CRTIMP basic_ios<char, char_traits<char> >; ??
2. why static?
Struct char_traits{
static void __cdecl assign(_E& _X, const _E& _Y);
}
3. s
From Dmwiki
Jump to: navigation, search
There is a requirement that wrapped CHtmlView into a COM for previewing all kinds of office document. It must hide all menu and toolbars for increase the viewing area and should support office XP\2003\2007.
For Office 2003 it is easy to do that. But for Word 2007, It doesn’t work! It stumppe us for several weeks. I googled and also posted this question in msdn newsgroup, nobody gives the correct solution.
Some MVP of Office said the new Office interface was consciously designed to NOT allow the developer as much freedom with which tools are provided to the user. You won't be able to recover this realestate completely.
Solution for Office 2003:
Dim iCounter As Integer
For iCounter = 1 To CommandBars.Count
Application.CommandBars(iCounter).Enabled = False
Next
Possible solution for Word 2007 we have tried:
One possibility would be to define and include an XML part for the Ribbon in the document's file structure. The Ribbon XML can set the ribbon to start from scratch( startFromScratch=TRUE) in CustomUI.xml. which would make it "empty". But you can't get rid of the big, round "Office" button that will contain a limited number of basic commands. But this could not hide all the ribbon area completely.The big round button and quick access area and some other command,such as "help",will remain.
Beyond that, the object model provides ToggleRibbon method, which will cycle between "collapsing" the ribbon to look like an old-style MenuBar and expanding it again.
The third possible solution is trying the Windows API to find the windows handle of the ribbon, and then use API to hide the windows. This solution did could hide the ribbon but another problem is we could not minimize it.
Correct Solution for Word 2007:
When an Office app is OLE hosted, you can toggle on and off the UI using an OLE command. Like this:
#include "exdispid.h"
OLECMDF cmd = QueryStatusWB( OLECMDID_HIDETOOLBARS);
if( !(cmd & OLECMDF_LATCHED))
ExecWB(OLECMDID_HIDETOOLBARS, OLECMDEXECOPT_PROMPTUSER, NULL, NULL);
现在的软件产品都强调"整合",像微软的各种产品都尽量整合在一起,其开发类产品比如Visual studio,Sql server management studio,还有新开发的 Express studio等等通过visual studio来整合,Office 系列更是整合的经典。 Autodesk现在也提了个Autodesk 3.0的概念,其中重要的一点是2D CAD, 3D CAD, PDM\PLM产品全部整合在一起,再结合ERP系统提供给用户的就是一整套Solution。 Dassault在这方面已经走在前面了。Google的g各种产品基本都通过其核心的搜索技术整合起来的。
使用数据挖掘解决问题:
• 消费者将购买什么产品?哪些产品会一起
销售?
• 标识将流失的消费者
• 市场状况如何,将会如何发展?
• 分析网站
• 确定营销活动是否成功
• 劣质数据
• 文本分析
常见数据挖掘算法:
• 贝叶斯Naïve Bayers
• 决策树Decision Trees
• 神经网络Neural Networks
• 关联规则Association Rules
• 聚类分析 Clustering
• 时序聚类分析 Sequence Clustering
• 时序 Time Series
使用数据挖掘解决问题
定义商务智能
支持平台
• 多维分析(比如OLAP)
• 数据挖掘
• 预测
• 业务分析
• 查询、报告和图表
• 知识管理
• 企业门户
• 数字仪表板(Digital Dashboard)
• 数据仓库
•……
数据挖掘的基本概念
Cube
• 没有个数限制(仅仅受可创建对象上限限
制)
• 使用XML进行存储
• 维(Dimensions)
• 度量(Measures)
• 属性(Attributes)
• 层次(Hierarchies)
BI基本业务需求的逻辑
• 计算— 可扩展的度量标准;
• 分组— 多角度;多层次;定制灵活…
• 比较— 多选择的可比系列;
• 排序— 多样化的排序规则;
• 筛选— 单值筛选、复合条件筛选;
• 综合运用
· ConfigurationcPramework
· Plug-IncFramework
· CachecFramework
· BusinesscLogiccFramework
· FactorycFramework
· DaracConnectioncFramework
· SettingscFramework
· SerialcFramework
· SecuritycFramework
· ProfilecFramework
· Context Framework
pointer
T const * p ó const T * p;
T * const p;
T const * const p ó const T * const p;
Character array literal.
Char* p = "kaven";
P[1] = 'A'; //no compile time error! But will got runtime error!!
Const char* cp = "kaven";
Cp[1] = 'A'; //compile error!!
Char ap[] = "kaven";
Ap[1] = 'A'; //ok!
・ Character array literals "kaven" is created by the compiler as a constant character array .
・ So suggest that use const char* if you don't want it to be changed.
・ If you want to be able to modify the string ,put it in array: char ap[];
Assignment and type cheching
Int d = 1;
Const int e = 2;
Int* pd = &d; //ok!
Int* pe = &e; //error! Can not assign the address of a const object to a non-const pointer.
//because you are saying you might change the object via the pointer.
Int const *cp = &e; //ok now.
Int * const cp = &e; //error too.
Int* pe = (int*)&e; //illegal but bad practice.
・ You can assign the address of a non-const object to a const pointer.
・ But you can't assign the address of a const object to a non-const pointer!
Function
Const T func( const T& a) const;
让函数返回一个常量值经常可以在不降低安全性和效率的情况下减少用户出错的几率,防止对返回值进行赋值或修改.
const T& a) const;
const成员函数的目的当然是为了指明哪个成员函数可以在const对象上被调用。
个成员函数为const的确切含义是什么?
bitwise constness的坚持者认为,当且仅当成员函数不修改对象的任何数据成员(静态数据成员除外)时,即不修改对象中任何一个比特(bit)时,这个成员函数才是const的。
尽量用"传引用"而不用"传值"
消除一些对拷贝构造函数的调用
避免了所谓的"切割问题(slicing problem)"。
引用几乎都是通过指针来实现的,所以通过引用传递对象实际上是传递指针。因此,如果是一个很小的对象――例如int――传值实际上会比传引用更高效。
2 ADO对象模型组成
与微软的其它数据访问模型DAO和RDO相比,ADO对象模型非常精炼,仅由三个主要对象Connection、Command、Recordset和几个辅助对象组成,其相互关系如图所示。Connection对象提供OLE DB数据源和对话对象之间的关联,它通过用户名称和口令来处理用户身份的鉴别,并提供事务处理的支持;它还提供执行方法,从而简化数据源的连接和数据检索的进程。Command对象封装了数据源可以解释的命令,该命令可以是SQL命令、存储过程或底层数据源可以理解的任何内容。Record set用于表示从数据源中返回的表格数据,它封装了记录集合的导航、记录更新、记录删除和新记录的添加等方法,还提供了批量更新记录的能力。其它辅助对象则分别提供封装ADO错误、封装命令参数和封装记录集合的列。
3 VC 调用ADO基本方法
1、 用import导入ADO 的 COM 文件msado15.dll
例如:
#import "C:\Program Files\Common Files\System\ADO\msado15.dll"\no_namespace |
2、COM 使用时初始化
HRESULT ComInit() |
3、建立数据库连接
HRESULT ConnectToDB( LPSTR pUserId , // 用户名 |
关闭一个库连接 如果连接状态有效,则用Close方法关闭它并赋于它空值。代码如下所示:
if(m_pConnection->State) |
4.执行一个SQL 查询,得到数据集(recordset)
_RecordsetPtr GetRecordSet(LPSTR strSql, _ConnectionPtr ptrConn) |
5.通过数据集(recordset)得到列的名称
HRESULT GetColumnNames( |
6.通过数据集(recordset)得到当前行记录
HRESULT getOneRecord( |
7.出错情况下错误信息的取得
void ErrorFunc(_com_error &pComError, _ConnectionPtr ptrConn); |
插入记录 可以先用AddNew()方法新增一个空记录,再用PutCollect(字段名,值)输入每个字段的值,最后再Update()更新到库中数据既可。其中变量m_Name和m_Age分别为姓名及年龄编辑框的成员变量名。代码所下所示:
try |
移动记录指针 移动记录指针可以通过MoveFirst()方法移动到第一条记录、MoveLast()方法移动到最后一条记录、MovePrevious()方法移动到当前记录的前一条记录、MoveNext()方法移动到当前记录的下一条记录。但我们有时经常需要随意移动记录指针到任意记录位置时,可以使用Move(记录号)方法来实现,注意: Move()方法是相对于当前记录来移动指针位置的,正值向后移动、负值向前移动,如:Move(3),当前记录是3时,它将从记录3开始往后再移动3条记录位置。代码如下所示:
try |
改记录中字段值 可以将记录指针移动到要修改记录的位置处,直接用PutCollect(字段名,值)将新值写入并Update()更新数据库既可。可以用上面方法移动记录指针,修改字段值代码如下所示:
try |
删除记录 删除记录和上面修改记录的操作类似,先将记录指针移动到要修改记录的位置,直接用Delete()方法删除它并用Update()来更新数据库既可。代码如下所示:
try |
关闭记录集 直接用Close方法关闭记录集并赋于其空值。代码如下所示:
m_pRecordset->Close(); |
3. CommandPtr智能指针,可以使用_ConnectionPtr或_RecordsetPtr来执行任务,定义输出参数,执行存储过程或SQL语句。
执行SQL语句 先创建一个_CommandPtr实例指针,再将库连接和SQL语句做为参数,执行Execute()方法既可。代码如下所示:
_CommandPtr m_pCommand; |
执行存储过程 执行存储过程的操作和上面执行SQL语句类似,不同点仅是CommandText参数中不再是SQL语句,而是存储过程的名字,如Demo。另一个不同点就是在Execute()中参数由adCmdText(执行SQL语句),改为adCmdStoredProc来执行存储过程。如果存储过程中存在输入、输出参数的话,需要使用到另一个智能指针_ParameterPtr来逐次设置要输入、输出的参数信息,并将其赋于_CommandPtr中Parameters参数来传递信息,有兴趣的读者可以自行查找相关书籍或MSDN。执行存储过程的代码如下所示:
_CommandPtr m_pCommand; |