锘??xml version="1.0" encoding="utf-8" standalone="yes"?> Consider this code: Starting with GCC 3.4.0, binding an rvalue to a const reference requires an accessible copy constructor. This might be surprising at first sight, especially since most popular compilers do not correctly implement this rule.
The C++ Standard says that a temporary object should be created in this context and its contents filled with a copy of the object we are trying to bind to the reference; it also says that the temporary copy can be elided, but the semantic constraints (eg. accessibility) of the copy constructor still have to be checked.
For further information, you can consult the following paragraphs of the C++ standard: [dcl.init.ref]/5, bullet 2, sub-bullet 1, and [class.temporary]/2.
Starting with GCC 4.3.0, GCC no longer gives an error for this case. This change is based on the intent of the C++ language committee. As of 2010-05-28, the final proposed draft of the C++0x standard permits this code without error.class A
{
public:
A();
private:
A(const A&); // private copy ctor
};
A makeA(void);
void foo(const A&);
void bar(void)
{
foo(A()); // error, copy ctor is not accessible
foo(makeA()); // error, copy ctor is not accessible
A a1;
foo(a1); // OK, a1 is a lvalue
}
]]>
鏂規1錛氫慨鏀笽E鐨勮緗細
鏂規2錛氭爣璁版帶浠朵負鑴氭湰瀹夊叏鐨?/p>
鍦ㄥ伐紼嬩腑澧炲姞澶存枃浠?cathelp.h
#ifndef _CATHELP_H_#define _CATHELP_H_#include <comcat.h>HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription);HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid);HRESULT UnRegisterCLSIDInCategory(REFCLSID clsid, CATID catid);#endif
澧炲姞cathelp.cpp
#include "cathelp.h"
HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription){ICatRegister* pcr = NULL ;HRESULT hr = S_OK ;hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr);
if (FAILED(hr))
return hr;
// Make sure the HKCR\Component Categories\{..catid...}
// key is registered
CATEGORYINFO catinfo;catinfo.catid = catid;catinfo.lcid = 0x0409 ; // english
// Make sure the provided description is not too long.
// Only copy the first 127 characters if it is
int len = wcslen(catDescription);
if (len>127)
len = 127;wcsncpy(catinfo.szDescription, catDescription, len);// Make sure the description is null terminated
catinfo.szDescription[len] = '\0';if(pcr)
{hr = pcr->RegisterCategories(1, &catinfo);pcr->Release();}return hr;
}HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid){// Register your component categories information.
ICatRegister* pcr = NULL ;HRESULT hr = S_OK ;hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr);
if (SUCCEEDED(hr))
{// Register this category as being "implemented" by
// the class.
CATID rgcatid[1] ;rgcatid[0] = catid;hr = pcr->RegisterClassImplCategories(clsid, 1, rgcatid);}if (pcr != NULL)
pcr->Release();return hr;
}HRESULT UnRegisterCLSIDInCategory(REFCLSID clsid, CATID catid){ICatRegister* pcr = NULL ;HRESULT hr = S_OK ;hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr);
if (SUCCEEDED(hr))
{// Unregister this category as being "implemented" by
// the class.
CATID rgcatid[1] ;rgcatid[0] = catid;hr = pcr->UnRegisterClassImplCategories(clsid, 1, rgcatid);}if (pcr != NULL)
pcr->Release();return hr;
}
淇敼 ocx鐨?DllRegisterServer 鏂規硶
#include "cathelp.h"
#include <objsafe.h>//for CATID_SafeForInitializing
#include "SafeocxtestCtl.h"
STDAPI DllRegisterServer(void)
{AFX_MANAGE_STATE(_afxModuleAddrThis);if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
return ResultFromScode(SELFREG_E_TYPELIB);
if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
return ResultFromScode(SELFREG_E_CLASS);
// 娉ㄥ唽鑴氭湰瀹夊叏
if( FAILED( CreateComponentCategory(CATID_SafeForScripting, L"Controls that are safely scriptable") ) )return ResultFromScode(SELFREG_E_CLASS);
if( FAILED( CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data") ) )return ResultFromScode(SELFREG_E_CLASS);
if (FAILED( RegisterCLSIDInCategory(
CSafeocxtestCtrl::guid, CATID_SafeForScripting) ))return ResultFromScode(SELFREG_E_CLASS);
if (FAILED( RegisterCLSIDInCategory(
CSafeocxtestCtrl::guid, CATID_SafeForInitializing) ))return ResultFromScode(SELFREG_E_CLASS);
return NOERROR;
}/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{AFX_MANAGE_STATE(_afxModuleAddrThis);if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
return ResultFromScode(SELFREG_E_TYPELIB);
if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
return ResultFromScode(SELFREG_E_CLASS);
// 鎺т歡瀹夊叏鍙嶅垵濮嬪寲
UnRegisterCLSIDInCategory( CSafeocxtestCtrl::guid, CATID_SafeForScripting);UnRegisterCLSIDInCategory( CSafeocxtestCtrl::guid, CATID_SafeForInitializing);return NOERROR;
}
緙栬瘧娉ㄥ唽灝監K浜嗐?/p>
濡傛灉瑕佹煡鐪媜cx鏄惁鏄剼鏈畨鍏ㄧ殑銆傚湪娉ㄥ唽琛℉KEY_CLASSES_ROOT\CLSID\OCX鐨刢lsid\Implemented Categories\ 涓嬬湅涓涓嬫湁娌℃湁鈥渰7DD95801-9882-11CF-9FA9-00AA006C42C4}鈥?鍜屸渰7DD95802-9882-11CF-9FA9-00AA006C42C4}鈥?/p>
涓嬪浘灝辨槸鑴氭湰瀹夊叏鐨勶細
鍙傝冿細http://support.microsoft.com/kb/161873/en-us
1: #瀹夎 渚濊禆鐨勫紑鍙戝寘2: yum groupinstall "Development Tools"
3:4: #瀹夎 wxGTK錛屾垜榪欎釜浣跨敤鐨勬槸2.8.*嫻嬭瘯鏄彲浠ョ殑5: yum install wxGTK*6:7: #涓嬭澆codeblocks瀹夎8: #http://www.codeblocks.org/downloads/binaries#linux9: # codeblocks-12.11-1.el6.i686.tar.bz2 (CentOS/RedHat 6)10:11: #鐒跺悗鏄В鍘嬪畨瑁?12: #瀹夎瀹屾垚鍚庯紝寤虹珛涓涓猦elloCB鐨勫伐紼嬶紝榪愯鏄彁紺?xTerm -T 澶辮觸銆傘傘?13: #浜庢槸14: yum install xterm15: # 瀹屾垚16:
1: #!/bin/sh
2: rpm -ivh mysql-5.0.77-4.el5_5.4.i386.rpm --nodeps
3: rpm -ivh perl-DBI-1.52-2.el5.i386.rpm
4: rpm -ivh perl-DBD-MySQL-3.0007-2.el5.i386.rpm
5:
6: rpm -ivh mysql-server-5.0.77-4.el5_5.4.i386.rpm
7: ##璁劇疆MySQL鏈嶅姟闅忕郴緇熷惎鍔ㄨ嚜鍚姩
8: chkconfig mysqld on
9: echo "璁劇疆MySQL鏈嶅姟闅忕郴緇熷惎鍔ㄨ嚜鍚姩鎴愬姛"
10: ##鍚姩MySQL鏈嶅姟
11: echo "鍚姩MySQL鏈嶅姟鎴愬姛"
12: /etc/rc.d/init.d/mysqld start
13: ##鍏抽棴Linux鐨勯槻鐏鍔熻兘
14: echo "闃茬伀澧欏凡鍏抽棴"
15: chkconfig iptables off
16: ##鎺堟潈root 榪滅▼
17: grant all privileges on *.* to root@'%' identified 123456';
18:
1: USE dbtest;2: DELIMITER ;;3:4: CREATE TRIGGER tr_ondel_test1 AFTER DELETE ON testtable15: FOR EACH ROW BEGIN6: DELETE FROM testtable2 where testtable2.FID= OLD.ID;7: END;;8:9: DELIMITER ;
鍒犻櫎瑙﹀彂鍣細
1: DROP TRIGGER dbtest.tr_ondel_test1;
鏌ョ湅瑙﹀彂鍣細
1: SHOW TRIGGERS FROM dbtest;2:3: SHOW TRIGGERS FROM dbtest LIKE 鈥?ondel%鈥?
瀵煎嚭瀛樺偍榪囩▼鍜岃Е鍙戝櫒錛?/p>
1: mysqldump -u root -p123456 --default-character-set=gbk --triggers dbtest >./bk.sql
1: mysql> use ivm;2: Database changed3: mysql> show variables %char%';4: +--------------------------+---------------------------------------------------------+
5: | Variable_name | Value |6: +--------------------------+---------------------------------------------------------+
7: | character_set_client | latin1 |8: | character_set_connection | latin1 |9: | character_set_database | gbk |10: | character_set_filesystem | binary |11: | character_set_results | latin1 |12: | character_set_server | latin1 |13: | character_set_system | utf8 |14: | character_sets_dir | D:\Program Files\MySQL\MySQL Server 5.0\share\charsets\ |15: +--------------------------+---------------------------------------------------------+
16: 8 rows in set (0.00 sec)17:18: mysql>
鍦?ivm鏁版嵁搴撲腑鍒涘緩瀛樺偍榪囩▼鍙婅皟鐢ㄧ粨鏋滃涓嬶細
1: delimiter ;;2: DROP PROCEDURE IF EXISTS r_test;3: CREATE PROCEDURE r_test(IN inStr VARCHAR(255) )4: BEGIN5: SELECT CHARSET(inStr);6: END;;7: delimiter ;8:9: #涓嬮潰鐨勮鍙ラ兘鎵ц澶辮觸,閿欒淇℃伅涓猴細Data too long for inStr' at row 110: call r_test('涓浗');
11: call r_test(_gbk'涓浗');
12: SET @china = _gbk'涓浗';
13: CALL r_test(@china);14: #鎵ц鎴愬姛 榪斿洖鍊兼槸錛歭atin115: call r_test('china');
16:17:18: # 鍒涘緩瀛樺偍榪囩▼涓緗簡 鍙傛暟鐨勫瓧絎﹂泦19: delimiter ;;20: DROP PROCEDURE IF EXISTS r_test2;21: CREATE PROCEDURE r_test2(IN inStr VARCHAR(255) character set gbk)22: BEGIN23: SELECT CHARSET(inStr);24: END;;25: delimiter ;26:27: #鎵ц鎴愬姛 榪斿洖鍊兼槸錛歡bk28: call r_test2('涓浗');
29: #鎵ц鎴愬姛 鍗充嬌鎵ц鍓嶈緗簡瀛楃闆嗘槸utf8榪斿洖鍊間粛鐒舵槸錛歡bk30: call r_test2(_utf8'涓浗');
31: #鎵ц鎴愬姛 榪斿洖鍊兼槸錛歡bk32: call r_test2('china');
緇撹錛?strong>鍒涘緩瀛樺偍榪囩▼鏃跺鏋滄病鏈夋寚瀹氬瓨鍌ㄨ繃紼嬬殑鍙傛暟鐨勫瓧絎﹂泦錛宮ysql鎬繪槸璁や負褰撳墠鐨勫弬鏁頒嬌鐢ㄧ殑鏄郴緇熺殑瀛楃闆?windows 涓?my.ini涓殑 default-character-set鎸囧畾)銆?/strong>
鍚﹀垯錛宮ysql鎬繪槸璁や負瀛樺偍榪囩▼鐨勫弬鏁頒嬌鐢ㄧ殑灝辨槸瀹氫箟鏃舵寚瀹氱殑瀛楃闆嗐?/strong>
闇瑕佹敞鎰忕殑鏄細涓婇潰鐨勮鍒欏拰褰撳墠鐨勮繛鎺ュ瓧絎﹂泦娌℃湁浠諱綍鐨勫叧緋伙紙浣跨敤mysql_options(m_pMySql, MYSQL_SET_CHARSET_NAME, "utf8")涔熶笉浼氭敼鍙橈級
1: DROP TABLE IF EXISTS alarm;
2: CREATE TABLE alarm ( id int(11) NOT NULL auto_increment, name varchar(255) default NULL,PRIMARY KEY (id));
3:
4: INSERT INTO alarm (name) aa');
5: INSERT INTO alarm (name) bb');
6:
7: DROP procedure if exists statalarm;
8: delimiter //
9: create procedure statalarm()
10: begin
11: SET @id = '1,2';
12:
13: SET @sql = 'select * from alarm where id IN (?)';
14: PREPARE stmt FROM @sql;
15: /*
16: 娉ㄦ剰 EXECUTE 鐨勬渶緇堣鍙ユ槸錛歴elect * from alarm where id IN ('1,2');
17: 鑰屼笉鏄?select * from alarm where id IN (1,2);
18: 榪欐槸鍥犱負濡傛灉鐢ㄦ埛鍙橀噺鐨勫兼槸瀛楃涓詫紝鍦‥XECUTE鏃?浼氳嚜鍔ㄧ殑鍦ㄥ彉閲忕殑鍊煎墠鍚庡姞涓婂紩鍙?
19: */
20: EXECUTE stmt USING @id;
21: DEALLOCATE PREPARE stmt;
22: /*
23: 濡傛灉鎯寵 緇勬垚select * from alarm where id IN (1,2);鍙互浣跨敤涓嬮潰鐨勮鍙?
24: */
25: SET @sql = concat('select * from alarm where id IN (',@id,')');
26: PREPARE stmt FROM @sql;
27: EXECUTE stmt ;
28: DEALLOCATE PREPARE stmt;
29:
30: end;//
31: delimiter ;
絎竴涓В鍐蟲柟妗堝氨鏄妸c.so鏀懼埌/usr/lib鎴?/usr/local/lib涓嬨?/p>
絎簩縐嶈В鍐蟲柟妗堟槸 鍦╩akefile鏂囦歡涓畾涔?鐜鍙橀噺 LD_LIBRARY_PATH 璁劇疆鍊間負c.so鐨勫瓨鏀劇洰褰曘?/p>
#闅愬紡鍔犺澆鐨剆o渚濊禆鐨剆o濡傛灉涓嶆斁鍦?usr/lib鎴?usr/local/lib涓嬶紝灝遍渶瑕佹寚瀹氬埌 LD_LIBRARY_PATH涓?br>export LD_LIBRARY_PATH=../lib:$LD_LIBRARY_PATH |
灝嗭細
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
淇敼涓猴細
1: #ifndef _FOO_H_
2: #define _FOO_H_
3: #include <stdio.h>
4: #include<iostream>
5: #include<string>
6:
7: class foo
8: {
9: public:
10: template<typename T>
11: void Saytype(const T&)
12: {
13: std::cout <<"unrecognized type !"<<std::endl;
14: }
15:
16: // 涓嬮潰鐨勫叏鐗瑰寲鍦?vc6涓嬬紪璇戦氳繃錛屼絾g++ 4.1.2 緙栬瘧澶辮觸
17: // template<>
18: // void Saytype<int>(const int & )
19: // {
20: // std::cout<<" type is int";
21: // }
22: // g++涓婂彲浠ヤ嬌鐢ㄩ噸杞芥潵浠f浛鍏ㄧ壒鍖?/span>
23: void Saytype(const int &)
24: {
25: std::cout<<" type is int";
26: }
27: };
28:
29: #endif
main.cpp
1: #include "../include/foo.h"
2:
3: int main()
4: {
5:
6: foo f;
7: f.Saytype((unsigned int)1);
8: f.Saytype((int)1);
9:
10: return 1;
11: }