青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

健康,快樂,勇敢的寧帥!!

努力、努力、再努力! 沒有什么能阻止我對知識的渴望。

 

"C++Templates The Complete Guide"讀書筆記----Chapter 7

Basic Template Terminology
1. "Class Template" or "Template Class"?
class template: the class is a template.
template class: a synonym(同義詞) for class template; to refer to classes generated from templates(由模板產生(實例化)的類). to refer to classes with a name that is a template-id.
Because of this imprecision, template class is avoided in this book.

2. Instantiation and specialzation
Instantiation: 實例化. The process of creating a regular class, function, or member function from a template by substituting actual values for its arguments is called template instantiation.
Specialzation:特例,在Chapter 3中有描述

3. Declarations vs Definitions
declaration is a C++ construct that introduces or reintroduceds a name into? a C++ scope.
class?C;?//?a?declaration?of?C?as?a?class
void?f(int?p);?//?a?declaration?of?f()?as?a?function?and?p?as?a?named?parameter
extern?int?v;?//?a?declaration?of?v?as?a?variable

Declarations become definitions when the details of their structure are made known or, in the case of variables, when storage space must be allocated.
class?C{};?//?definition(and?declaration)?of?class?C
void?f(int?p){?//?defini
???std::cout<<?p?<<?std::endl;
}


extern?int?v?=?1;??//?an?initializer?makes?this?a?definition?for?v

int?w;???//?global?variable?declaration?not?preceded?by?extern?are?also?definitions
By extension, the declaration of?a class template or function template is called a definition if it has a body, Hence,
template?<typename?T>
void?func(T);
is a declaration that is not a definition, whereas
template?<typename?T>
class?S{};
is in fact a definition

posted @ 2006-12-03 15:02 ningfangli 閱讀(117) | 評論 (0)編輯 收藏

"C++Templates The Complete Guide"讀書筆記----Chapter 6

Using Templates in Practice

1. Templates challenge the classic compiler-plus-linker model. Therefore there are different approaches to organize template code: the inclusion model, explicit instantiation, and the separation model
Most C and C++ programmers organize their nontemplate code largely as follows:
1) Classes and other types are entirely placed in header files.
2) For global variables and (noninline) functions, only a declaration is put in a header file, and the definition goes into a so-called dot-C file.
The works well: It makes the needed type definition easily available throughout the program and avoids duplicate definition errors on variables and functions from the linker.
With the convention in mind, we declare the template in a header file:
#ifndef?MYFIRST_HPP
#define?MYFIRST_HPP

//?declaration?of?template
template?<typename?T>?
void?print_typeof?(T?const&);

#endif?//?MYFIRST_HPP
The implementation of the function is placed in a dot-C file:
#include?<iostream>
#include?
<typeinfo>
#include?
"myfirst.hpp"

//?implementation/definition?of?template
template?<typename?T>
void?print_typeof?(T?const&?x)
{
????std::cout?
<<?typeid(x).name()?<<?std::endl;
}
Finally, we use the template in another dot-C file, into which our template declaration is #include:
#include?"myfirst.hpp"

//?use?of?the?template
int?main()
{
????
double?ice?=?3.0;
????print_typeof(ice);??
//?call?function?template?for?type?double
}

A C++ compiler will most likely accept this program without any problems,but the linker will probably report an error, implying that there is no definition of the function print_typeof().
In order for a template to be? instantiated, the compiler must know which definition should be instantiated and for what template arguments it should be instantiated. Unfortunately, these two pieces of information are in files that are compiled separatedly. Therefore, when our compiler sees the call to print_typeof() but has no definition in sight to instantiate this function for double, it just assumes that such a definition is provided elsewhere and creates a reference(for the linker to resolve,linker) to that definition. On the other hand, when the compiler processes the file myfirst.cpp, it has no indication at that point that it must instantiate the template definition it contains for specific arguments.

The Inclusion Model
Rewrite the header-file, including template definition.
#ifndef?MYFIRST_HPP
#define?MYFIRST_HPP


#include?
<iostream>
#include?
<typeinfo>

//?declaration?of?template
template?<typename?T>?
void?print_typeof?(T?const&
);

//?implementation/definition?of?template

template?<typename?T>
void?print_typeof?(T?const&?x)
{
????std::cout?
<<?typeid(x).name()?<<
?std::endl;
}


#endif?//?MYFIRST_HPP
disadvantage: the cost is not the result of size of the template definition itself, but the result of the fact that we must also include the header used by the definition of our template-in the case <iostream> and <typeinfo>.\

Explicit Instantiation
To avoid above linker error we can add the following file to our program:
#include?"myfirst.cpp"

//?explicitly?instantiate?print_typeof()?for?type?double
template?void?print_typeof<double>(double?const&);
disadvantage: We must carefully keep track of which entities to instantiate. For large projects this quickly becomes an excessive burden.
advantage:
the instantiation can be tuned to the needs of the program.
The overhead of large header is avoided.
The source code of template definition can be kept hidden, but then no additional instantiations can be created by a client program.
Finally, for some applications it can be useful to control the exact location(that is, the object file)of a template instance.

Separation model

2. Usually you should use the inclusion model
3. By separating template code into different header files for declarations and definitions, you can more easily switch between the inclusion model and explicit instantiation
4. The C++ standard defines a separate compilation model for templates(using the keyword export). It is not yet widely available, however.
5. To take advantage of precompiled headers, be sure to keep the same order for #include directives.
6. Debuggin code with templates can be challenging
7. Template instances may have very long names

posted @ 2006-12-03 12:38 ningfangli 閱讀(188) | 評論 (0)編輯 收藏

網上推薦的殺毒組合

殺毒就用卡巴:(不敢恭維,原來用過,很耗資源)
木馬就用Ewido:(剛裝上,破解比較麻煩,文件中有整個包,看到大家的評價不錯,官方下載:http://download.ewido.net/ewido-setup.exe;)
防火墻就用ZoneAlarm:? (還是不用的好,這個好麻煩,總要你確認是否允許聯網,就用xp的防火墻吧)

這三個合起來用,可以使得系統堅若磐石
它們每個都是當今世界最強的,不用是你的損失!!

卡巴和ZoneAlarm同時安裝時,記得在卡巴的實時保護設置里,把那個禁止網絡攻擊保護打上鉤!!!!!!不然會沖突!!! 切記!!!(如果只安裝卡巴的話就不用這樣做了)

posted @ 2006-12-02 01:30 ningfangli 閱讀(194) | 評論 (0)編輯 收藏

不勝其煩的網絡病毒!

今天晚上,已經是我兩周以來第二次恢復筆記本的系統了,好在有true image啊!。原因都是一樣:在上網找一些軟件時,不幸中招。
我還一直很小心不斷升級Symantec。將防火墻開啟。也真不知道哪個防毒軟件真的好使,也不知道怎么這么多人希望弄這些病毒!
無奈!

posted @ 2006-12-02 00:46 ningfangli 閱讀(113) | 評論 (0)編輯 收藏

"C++Templates The Complete Guide"讀書筆記----Chapter 5

     摘要: 1. To access a type name that depends on a template parameter, you have to?qualify(?修改,修飾) the name with a leading typename//?print?elements?of?an?STL?containertemplate?<typename?T>void?printcol...  閱讀全文

posted @ 2006-12-01 15:41 ningfangli 閱讀(174) | 評論 (0)編輯 收藏

"C++Templates The Complete Guide"讀書筆記----Chapter 4

Chapter 4 Nontype Template Parameters
1. Templates can have template parameters that are values rather than types
With this class, user of the stack could specify this size of the array as the maximum size needed for stack elements
template?<typename?T,?int?MAXSIZE>
class?Stack?{
??
private:
????T?elems[MAXSIZE];????????
//?elements
????int?numElems;????????????//?current?number?of?elements

??
public:
????Stack();??????????????????
//?constructor
????void?push(T?const&);??????//?push?element
????void?pop();???????????????//?pop?element
????T?top()?const;????????????//?return?top?element
????bool?empty()?const?{??????//?return?whether?the?stack?is?empty
????????return?numElems?==?0;
????}

????
bool?full()?const?{???????//?return?whether?the?stack?is?full
????????return?numElems?==?MAXSIZE;
????}

}
;

//?constructor
template?<typename?T,?int?MAXSIZE>
Stack
<T,MAXSIZE>::Stack?()
??:?numElems(
0)???????????????//?start?with?no?elements
{
????
//?nothing?else?to?do
}


template?
<typename?T,?int?MAXSIZE>
void?Stack<T,MAXSIZE>::push?(T?const&?elem)
{
????
if?(numElems?==?MAXSIZE)?{
????????
throw?std::out_of_range("Stack<>::push():?stack?is?full");
????}

????elems[numElems]?
=?elem;???//?append?element
????++numElems;???????????????//?increment?number?of?elements
}


template
<typename?T,?int?MAXSIZE>
void?Stack<T,MAXSIZE>::pop?()
{
????
if?(numElems?<=?0)?{
????????
throw?std::out_of_range("Stack<>::pop():?empty?stack");
????}

????
--numElems;???????????????//?decrement?number?of?elements
}


template?
<typename?T,?int?MAXSIZE>
T?Stack
<T,MAXSIZE>::top?()?const
{
????
if?(numElems?<=?0)?{
????????
throw?std::out_of_range("Stack<>::top():?empty?stack");
????}

????
return?elems[numElems-1];??//?return?last?element
}
2. You can also define nontype parameters for function templates.
template?<typename?T,?int?VAL>
T?addValue?(T?
const&?x)
{
????
return?x?+?VAL;
}
However, according to the current standard, sets of overloaded functions cannot? be used for template parameter deduction. Thus, you have to cast to the exact type of the function template argument:
std::transform(source.begin(),source.end(),//?start?and?end?of?source
???????????????dest.begin(),//?start?of?destination
???????????????(int(*)(int?const&))addValue<int,5>);//operation
There is a proposal for the standard to fix this behavior so that the cast isn't necessary.
2. You cannot use floating-point numbers, class-type objects, and objects with internal linkage(such as string literals) as arguments for nontype template parameters

posted @ 2006-11-26 19:50 ningfangli 閱讀(144) | 評論 (0)編輯 收藏

斷點失效解決方法

http://www.controlav.com/bphelper/start.asp

posted @ 2006-11-26 17:02 ningfangli 閱讀(139) | 評論 (0)編輯 收藏

"C++Templates The Complete Guide"讀書筆記----Chapter 3

Chapter 3 Class Templates
1. A clas template is a class that is implemented with one or more type parameters left open
#include?<vector>
#include?
<stdexcept>

template?
<typename?T>
class?Stack?{
??
private:
????std::vector
<T>?elems;?????//?elements

??
public:
????
void?push(T?const&);??????//?push?element
????void?pop();???????????????//?pop?element
????T?top()?const;????????????//?return?top?element
????bool?empty()?const?{??????//?return?whether?the?stack?is?empty
????????return?elems.empty();
????}

}
;

template?
<typename?T>
void?Stack<T>::push?(T?const&?elem)
{
????elems.push_back(elem);????
//?append?copy?of?passed?elem
}


template
<typename?T>
void?Stack<T>::pop?()
{
????
if?(elems.empty())?{
????????
throw?std::out_of_range("Stack<>::pop():?empty?stack");
????}

????elems.pop_back();?????????
//?remove?last?element
}


template?
<typename?T>
T?Stack
<T>::top?()?const
{
????
if?(elems.empty())?{
????????
throw?std::out_of_range("Stack<>::top():?empty?stack");
????}

????
return?elems.back();??????//?return?copy?of?last?element
}
2. To use a class template, you pass the open types as template arguments. The class template is the instantiated(and compiled) for these types
3. For class templates, only those menber funcitons that are called are instantiated
This , of course, saves time and space. It has the additional benefit that you can instantiate a class even for those types that cannot perform all the operations of all the menber functions, as long as these member functions are not called.
Note that you have to put whitespace between the two closing? template brackets. If you don't do this, you are using operator>>,which results in a syntax error:
Stack<Stack<int>>?intStackStack;?//ERROR:>>is?not?allowed
4. You can specialize calss templates for certain types
template<>
class?Stack<std::string>?{
??
private:
????std::deque
<std::string>?elems;??//?elements

??
public:
????
void?push(std::string?const&);??//?push?element
????void?pop();?????????????????????//?pop?element
????std::string?top()?const;????????//?return?top?element
????bool?empty()?const?{????????????//?return?whether?the?stack?is?empty
????????return?elems.empty();
????}

}
;

void?Stack<std::string>::push?(std::string?const&?elem)
{
????elems.push_back(elem);????
//?append?copy?of?passed?elem
}


void?Stack<std::string>::pop?()
{
????
if?(elems.empty())?{
????????
throw?std::out_of_range
????????????????(
"Stack<std::string>::pop():?empty?stack");
????}

????elems.pop_back();?????????
//?remove?last?element
}


std::
string?Stack<std::string>::top?()?const
{
????
if?(elems.empty())?{
????????
throw?std::out_of_range
????????????????(
"Stack<std::string>::top():?empty?stack");
????}

????
return?elems.back();??????//?return?copy?of?last?element
}


ps:也就是所謂的特定版本,模板元編程中的關鍵。
5. You can partially specialize class templates for certain types
If more than one partial specilalization matches equally well, the declaration is ambiguous
6. You can define default values for class template parameters.These may refer to previous template parameters

posted @ 2006-11-26 16:15 ningfangli 閱讀(172) | 評論 (0)編輯 收藏

"C++Templates The Complete Guide"讀書筆記----Chapter 2

這段時間在通過"C++Templates The Complete Guide"這本書學習Templates。發現這本書確實不錯:語言簡明,內容翔實。特別是每章后面的Summery總結得很好。這份讀書筆記就已這個Summery為基礎寫的。

書前面的Prefece和Chapter 1就跳過了。既然來學習Templates就已經知道它的重要性了。

??????????????????????????????? Chapter 2 FunctionTemplates
1. Function templates define a family of functions for different template arguments;

template? < typename?T >
inline?T?
const & ?max?(T? const & ?a,?T? const & ?b)
{
????
// ?if?a?<?b?then?use?b?else?use?a
???? return ??a? < ?b? ? ?b?:?a;
}

2. When you pass template arguments, function templates are instantiated for these argument types.
The process of replacing templates parameters by concrete types is called instantiatin.(at compiled time)
3. You can explicitly qualify the template parameters

{
// ?because?no?automatic?type?conversion?if?allowed?in?templates,so
max(static_cast < double > ( 4 ), 4.2 ) // cast?the?arguments?so?that?they?both?match
max < double > ( 4 , 4.2 ) // ?specify?explicitly?the?type?of?T
}

4. You can overload funciton templates

inline? int ? const & ?max?( int ? const & ?a,? int ? const & ?b)?
{
????
return ??a? < ?b? ? ?b?:?a;
}


// ?maximum?of?two?values?of?any?type
template? < typename?T >
inline?T?
const & ?max?(T? const & ?a,?T? const & ?b)
{
????
return ??a? < ?b? ? ?b?:?a;
}


// ?maximum?of?three?values?of?any?type
template? < typename?T >
inline?T?
const & ?max?(T? const & ?a,?T? const & ?b,?T? const & ?c)
{
????
return ?::max?(::max(a,b),?c);
}


int ?main()
{
????::max(
7 ,? 42 ,? 68 );????? // ?calls?the?template?for?three?arguments
????::max( 7.0 ,? 42.0 );????? // ?calls?max<double>?(by?argument?deduction)
????::max( ' a ' ,? ' b ' );?????? // ?calls?max<char>?(by?argument?deduction)
????::max( 7 ,? 42 );????????? // ?calls?the?nontemplate?for?two?ints
????::max <> ( 7 ,? 42 );??????? // ?calls?max<int>?(by?argument?deduction)
????::max < double > ( 7 ,? 42 );? // ?calls?max<double>?(no?argument?deduction)
????::max( ' a ' ,? 42.7 );????? // ?calls?the?nontemplate?for?two?ints
}

ps: the overload resolution process normally prefers this nontemplate over one generated from the template. the fourth call falls under this rule.
5. When you overload function templates, limit your changes to specifying template parameters explicitly

{
max
<> ( 7 , 42 ); // call?max<int>?(by?argument?deduction)
}


6. Make sure you see all overloaded versions of funciton templates before you call them

template? < typename?T >
inline?T?
const & ?max?(T? const & ?a,?T? const & ?b)
{
????
return ??a? < ?b? ? ?b?:?a;
}


// ?maximum?of?three?values?of?any?type
template? < typename?T >
inline?T?
const & ?max?(T? const & ?a,?T? const & ?b,?T? const & ?c)
{
????
return ?max?(max(a,b),?c);?? // ?uses?the?template?version?even?for?ints
}
?????????????????????????????? // ?because?the?following?declaration?comes
???????????????????????????????
// ?too?late:
// ?maximum?of?two?int?values
inline? int ? const & ?max?( int ? const & ?a,? int ? const & ?b)?
{
????
return ??a? < ?b? ? ?b?:?a;
}


?

posted @ 2006-11-26 15:24 ningfangli 閱讀(187) | 評論 (0)編輯 收藏

建立這個站點

? 昨天晚上建立了這個博客。主要想把關于自己學習C++的知識、人生的感悟、還有從網上看到的好東西等等都放在這里。但建立的時候為博客的名字,我和老婆絞盡腦汁。想的名字不是太俗,就是太怪。于是我們就想到問問我兩歲半的兒子,正處于睡意懵懂中的兒子大聲說:“寧帥!”。哈哈。這個是兒子給自己起的名字。好就叫這個了。至于“健康、快樂、勇敢”是我們對他的希望。

posted @ 2006-11-23 10:51 ningfangli 閱讀(131) | 評論 (0)編輯 收藏

僅列出標題
共4頁: 1 2 3 4 

導航

統計

公告

Dict.CN 在線詞典, 英語學習, 在線翻譯

常用鏈接

留言簿(4)

隨筆檔案

文章分類

文章檔案

搜索

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美高清视频www夜色资源网| 久久免费午夜影院| 91久久精品一区二区别| 亚洲一区二区三区成人在线视频精品| 一区在线免费| 午夜精品网站| 亚洲自拍偷拍福利| 欧美日韩福利视频| 亚洲第一在线综合在线| 红杏aⅴ成人免费视频| 亚洲视频视频在线| 9色精品在线| 免费视频一区| 亚洲第一区中文99精品| 狠狠v欧美v日韩v亚洲ⅴ| 性欧美18~19sex高清播放| 亚洲综合色噜噜狠狠| 欧美视频精品一区| 夜夜爽99久久国产综合精品女不卡 | 亚洲免费高清视频| 亚洲狠狠婷婷| 免费成人av| 欧美激情综合| 亚洲另类一区二区| 欧美人成在线视频| 日韩一区二区高清| 亚洲一区在线播放| 国产精品久99| 午夜电影亚洲| 久久精品午夜| 一区二区三区在线视频观看| 久久久国产精品亚洲一区| 美女国产一区| 亚洲黄色免费电影| 欧美精品日韩一本| 亚洲毛片播放| 香蕉亚洲视频| 国产又爽又黄的激情精品视频| 欧美在线亚洲综合一区| 免费成人黄色| 亚洲美女av黄| 欧美视频观看一区| 午夜精品av| 美女亚洲精品| 一本色道久久综合一区| 国产精品yjizz| 午夜在线播放视频欧美| 久久欧美中文字幕| 亚洲人成人99网站| 欧美日韩一区不卡| 香港成人在线视频| 欧美成人一区在线| 亚洲一区二区黄色| 国产一区二区三区四区老人| 久久尤物视频| 一二三四社区欧美黄| 久久久久久久91| 亚洲欧洲另类| 国产精品夜夜夜一区二区三区尤| 久久精品成人| 99精品欧美一区二区三区| 久久久久**毛片大全| 亚洲另类在线一区| 国产日韩精品综合网站| 欧美成va人片在线观看| 亚洲一区二区三区色| 欧美肥婆bbw| 亚洲四色影视在线观看| 欧美福利影院| 亚洲欧美日韩国产成人| 欧美激情一二区| 午夜日韩福利| 亚洲精品久久久久久久久| 国产美女一区二区| 欧美精品少妇一区二区三区| 欧美一级淫片aaaaaaa视频| 亚洲国产精品专区久久| 久久gogo国模裸体人体| av成人免费在线观看| 黄色成人精品网站| 国产精品久久久久久久9999 | 亚洲精品日韩久久| 久久久久久网址| 亚洲综合精品四区| 99精品视频免费全部在线| 精品av久久707| 国产精品免费一区二区三区在线观看| 免费成人激情视频| 久久精品国产第一区二区三区最新章节 | 欧美成人国产一区二区| 欧美影院成人| 亚洲专区免费| 亚洲无毛电影| 亚洲精品乱码久久久久久日本蜜臀| 久久夜色精品国产噜噜av| 亚洲欧美日本在线| 一区二区三区欧美在线观看| 亚洲激情欧美| 亚洲黄一区二区三区| …久久精品99久久香蕉国产| 国产一区二三区| 国产一级一区二区| 国产一区二区久久久| 国产欧美午夜| 国产欧美在线播放| 国产精品一国产精品k频道56| 欧美亚洲成人免费| 欧美性生交xxxxx久久久| 欧美三区在线视频| 欧美四级在线观看| 国产精品国码视频| 国产精品美女主播| 国产精品一区视频| 国产亚洲欧美另类一区二区三区| 国产欧美日韩视频一区二区三区| 国产精品免费观看视频| 国产精品毛片a∨一区二区三区|国 | 亚洲国产精品第一区二区三区| 国产一区久久久| 伊大人香蕉综合8在线视| 在线不卡a资源高清| 亚洲激情啪啪| 一区二区av在线| 亚洲在线中文字幕| 久久不射中文字幕| 久久综合伊人77777蜜臀| 欧美91视频| 亚洲美女免费精品视频在线观看| 一本一本久久| 先锋影音国产精品| 久久综合狠狠综合久久激情| 欧美成人激情在线| 欧美视频日韩视频在线观看| 国产伦精品一区二区三区| 国内精品免费在线观看| 91久久精品久久国产性色也91| 夜夜精品视频一区二区| 翔田千里一区二区| 欧美成人一区二区三区在线观看 | 午夜精品美女久久久久av福利| 欧美在线网址| 欧美精品麻豆| 国产人妖伪娘一区91| 亚洲国产成人久久综合一区| 亚洲午夜女主播在线直播| 久久精品亚洲乱码伦伦中文 | 欧美午夜理伦三级在线观看| 国产亚洲精品一区二555| 亚洲精品中文字幕女同| 亚洲欧美日韩在线播放| 免费观看久久久4p| 一区二区三区四区五区视频| 欧美在线视频全部完| 欧美人在线观看| 黄色国产精品一区二区三区| 一区二区三区日韩精品| 久久综合久久综合久久综合| 99精品国产热久久91蜜凸| 欧美一区二区在线视频| 欧美日韩精品三区| 伊人蜜桃色噜噜激情综合| 亚洲午夜在线观看| 亚洲盗摄视频| 久久av红桃一区二区小说| 欧美午夜片在线观看| 亚洲黄色在线视频| 久久久久国产免费免费| 亚洲天堂av图片| 欧美韩国一区| 亚洲第一区在线观看| 久久国内精品自在自线400部| 亚洲激情视频在线播放| 久久九九电影| 国产欧美日韩精品丝袜高跟鞋| 亚洲午夜视频在线观看| 亚洲国产精品成人一区二区| 久久成人一区二区| 国产精品素人视频| 亚洲欧美在线磁力| 一本色道久久精品| 欧美区二区三区| 日韩亚洲欧美中文三级| 欧美国产精品v| 美女图片一区二区| 在线观看不卡| 美女黄毛**国产精品啪啪| 欧美一区深夜视频| 国产日韩欧美亚洲| 欧美在线视频日韩| 亚洲欧美日韩国产中文在线| 国产精品国产三级国产普通话蜜臀| 一区二区三区精品久久久| 亚洲精品久久久久久久久久久久| 免费一级欧美在线大片| 亚洲精品国产欧美| 亚洲人成网站在线观看播放| 欧美精品www在线观看| 99亚洲伊人久久精品影院红桃| 亚洲人成在线观看一区二区| 欧美精品网站|