- 浏览: 399984 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
There are three kinds of friends declaration that may appear within a class template.
A nontemplate friend class or friend function.
/** - A nontemplate friend class or friend function. * A nontemplate friend class or friend function. In the following example, the function foo(), the member function bar() * the member function bar() and the class foobar are friends to all instantiation of the class tepmlate QueueItem . * * this is a one-to-one relationship and the fiends are determined/fixed right in the declaration (there is only one declaration of the friends) */ class Foo { void bar(); }; class foobar {} template <class T> class QueueItem { friend class foobar; friend void foo(); friend void Foo::bar(); };
It is the one-to-one relationship, and there is only one function . and no matter how many instance of the function template , there is only one declaration.
A Bound friend class template or function template.
/** - A bound friend class template or function template * this is a one-to-one relationship and the friends are not determined (the friends is created when the class is instantiated).- */ template <class Type> class foobar { // }; template <class Type> void foo(QueueItem<Type>); template <class Type> class Queue { void bar(); }; template <class Type> class QueueItem { friend class foobar<Type>; friend class foo<Type>(QueueItem<Type>); friend class Queue<Type>::bar(); };
this is also a one-to-one relationship, but for a particular instantiation of the class template, there is one friend for that instantiation.
An unbound friend class
/** - An unbound friend class template or function template * unbound friend classes are multiple-to-one relationship * */ template <class Type> template QueueItem { friend class foobar; template <class T> friend void foo(QueueItem<T>); template <class T> friend void Queue<T>::bar(); };
There is a one-to-many relationship, where for a particular instantiation of the class template, there could be many function/classes that are the friends of the class template instantion.
发表评论
-
不安装Visual Studio,只用Windows SDK搭建VC环境
2013-12-31 21:52 15342首先你需要下载的是 Microsoft Windows S ... -
rpath - runtime search path
2013-04-03 11:36 1013RPath is a very interesting to ... -
C++ - autogenerated copy constructor and assignment operator gotchas
2013-01-24 13:32 772It has been changed that the s ... -
c++ - rethrow a exception gotchas
2012-12-23 10:57 964As in my prevoius example in j ... -
c++ -typeid operator
2012-10-15 22:30 1060typeid is the one of the meager ... -
c++ - dynamic_cast revisit
2012-10-14 21:21 774There are several built-in type ... -
c++ - virtual inheritance example 1
2012-10-14 15:25 826we have discussed the virtual i ... -
c++ - virtual inheritance
2012-10-12 08:58 980As we have discussed in the pos ... -
c++ type of inheritance
2012-09-28 08:58 754There are 3 types of inheritanc ... -
c++ - vritually virtual new
2012-09-27 23:59 961Let's see what if we want to cl ... -
c++ - virtual destructor
2012-09-27 22:01 976As we all know that virtual des ... -
c++ - vritual function and default arguments
2012-09-27 08:56 995As we all know that we virtual ... -
c++ - template specialization and partial specialization
2012-09-26 22:38 1331in this post, we are going to e ... -
c++ - member template in class template
2012-09-26 08:19 940class member template can be us ... -
c++ template class and the pattern to use its friends
2012-09-25 23:47 987template class may defined thei ... -
c++ - class template default parameters
2012-09-25 08:18 856the template has parameter, it ... -
c++ - operator new and delete and an example of linked list stores by new/delete
2012-09-24 07:53 589The operator new and delete ope ... -
c++ - delete(void *, size_t) or delete(void *)
2012-09-24 07:18 1172In my previous dicuss, we have ... -
c++ - placement operator new() and the operator delete()
2012-09-23 15:22 875A class member operator new() c ... -
c++ - overloaded subscript operator - []
2012-09-23 08:50 1189You can overload the subscript ...
相关推荐
除了通过完整路径访问命名空间成员,C++还提供了两种简化方式:`using directive`和`using declaration`。 - **using directive**: ``` using namespace <命名空间名称>; ``` 这将导入命名空间中的所有成员,...
3D-vertex-declaration-system.zip,用于管理三维图形顶点结构。2013年为个人游戏引擎撰写。,3D建模使用专门的软件来创建物理对象的数字模型。它是3D计算机图形的一个方面,用于视频游戏,3D打印和VR,以及其他应用...
2. declaration_list -> declaration_list declaration | declaration 3. declaration -> var_declaration | fun_declaration 4. var_declaration -> type_specifier ID; | type_specifier ID [ NUM ]; 5. type_...
一个文件用于保存程序的声明(declaration),称为头文件。另一个文件用于保存程序的实现(implementation),称为定义(definition)文件。 C++/C程序的头文件以“.h”为后缀,C程序的定义文件以“.c”为后缀,C++...
### TI-EU Declaration of Conformity (DoC)U-综合文档 #### 一、概述 **TI-EU Declaration of Conformity (DoC)U** 文件是德州仪器(Texas Instruments Incorporated, 简称 TI)为其产品所发布的符合性声明。这份...
- **Class Template Argument Deduction:** Use CTAD (Class Template Argument Deduction) to make template class instantiation more concise. - **Designated Initializers:** Use designated initializers for ...
在C++中,如果在比较中使用的常量超出范围,会出现constant out of range in comparison错误。在比较中,需要确保常量在合法的范围内。 Conversion may lose significant digits(转换时会丢失意义的数字) -------...
For example, if your header file uses the File class in ways that do not require access to the declaration of the File class, your header file can just forward declare class File; instead of having ...
- C++ 2.1 support, including the new nested class specifications, and support of C++ 3.0 templates. - Support for pre-compiled headers for substantial time savings during subsequent recompiles. ...
Files contained in apt-mirror-api-0.1.jar: META-INF/MANIFEST.MF META-INF/maven/com.moparisthebest.aptIn16/apt-mirror-api/pom.properties META-INF/maven/...
可重载声明(Overloadable declarations)、声明匹配(Declaration matching)、重载解析(Overload resolution)、重载函数的地址(Address of overloaded function)、重载运算符(Overloaded operators)、内建...
export class MyClass {} } namespace MyModule { export const myConstant = 42; } ``` 合并后的`MyModule`将包含`MyClass`类和`myConstant`常量。命名空间的这种合并使得导入和使用第三方库时更加灵活。 总的...
Based on the provided information from the file "Addison.Wesley.C++.by.Dissection.2002.pdf," we can derive a comprehensive overview of the C++ programming language as covered in this text. The book is...
Too many type in declaration -----------------说明中类型太多 houjiuming Too much auto memory in function -----------------函数用到的局部存储太多 Too much global data defined in file ----------------...
- C++ 2.1 support, including the new nested class specifications, and support of C++ 3.0 templates. - Support for pre-compiled headers for substantial time savings during subsequent recompiles. ...
- **declaration-specifiers:** (storage-class-specifier | type-specifier | type-qualifier)+ - **storage-class-specifier:** ("auto" | "register" | "static" | "extern" | "typedef") - **type-specifier:...
CSS声明排序器 一个Node.js模块和插件,可根据其属性名称对CSS,SCSS或Less声明进行排序。 确保样式井井有条,更一致且井井有条...该软件包的目标是在构建过程中对项目的源代码进行排序,或者减小分布式CSS压缩后的...