友元是一种定义在类外部的普通函数或类,但它需要在类体内进行说明,为了与该类的成员函数加以区别,在说明时前面加以关键字friend。友元不是成员函数,但是它可以访问类中的私有成员。友元的作用在于提高程序的运行效率,但是,它破坏了类的封装性和隐藏性,使得非成员函数可以访问类的私有成员。...
                            
                            
                                分类:
编程语言   时间:
2014-07-29 22:09:02   
                                阅读次数:
293
                             
                    
                        
                            
                            
                                Problem Description
Recently, Doge got a funny birthday present from his new friend, Protein Tiger from St. Beeze College. No, not cactuses. It's a mysterious blackbox.
After some research, Doge f...
                            
                            
                                分类:
其他好文   时间:
2014-07-29 17:44:32   
                                阅读次数:
267
                             
                    
                        
                            
                            
                                初初认识jQuery的not选择器,想要实现的功能是,点击第一个div,显示第二个div,点击第一个div以外的地方,隐藏第二个div。具体代码如下:Welcome to My Homepage我是按钮I live in Duckburg.My best friend is Mickey.需要注意的...
                            
                            
                                分类:
Web程序   时间:
2014-07-29 17:41:02   
                                阅读次数:
192
                             
                    
                        
                            
                            
                                Description
A friend of you has just bought a new computer. Until now, the most powerful computer he ever used has been a pocket calculator. Now, looking at his new computer, he is a bit disappointed...
                            
                            
                                分类:
其他好文   时间:
2014-07-29 15:07:09   
                                阅读次数:
335
                             
                    
                        
                            
                            
                                贪心+优先队列+问题分解对x,y 分开处理当 xl 2 #include 3 #include 4 #include 5 using namespace std; 6 7 struct node { 8 int l,r; 9 int id;10 friend bool...
                            
                            
                                分类:
其他好文   时间:
2014-07-28 23:42:54   
                                阅读次数:
251
                             
                    
                        
                            
                            
                                用优先队列实现
模板:
struct node
{
    int pos, dist;
    friend bool operator  b.dist;
    }
};
int Dijkstra(int n,int start,int end)
{
    bool visited[maxn]...
                            
                            
                                分类:
其他好文   时间:
2014-07-28 00:07:00   
                                阅读次数:
305
                             
                    
                        
                            
                            
                                Problem DescriptionThere is a town with N citizens. It is known that some pairs of people are friends. According to the famous saying that “The friend...
                            
                            
                                分类:
其他好文   时间:
2014-07-27 22:26:19   
                                阅读次数:
199
                             
                    
                        
                            
                            
                                优先队列用法在优先队列中,优先级高的元素先出队列。标准库默认使用元素类型的 qi;通过, greater >qi2;其中第二个参数为容器类型。第二个参数为比较函数。故示例2中输出结果为:2 3 5 6 9第三种方法:自定义优先级。struct node{ friend bool operato...
                            
                            
                                分类:
其他好文   时间:
2014-07-26 00:19:06   
                                阅读次数:
306
                             
                    
                        
                            
                            
                                索引的原文档(Document)。为了方便说明索引创建过程,这里特意用两个文件为例:文件一:Students should be allowed to go out with their friends, but not allowed to drink beer.文件二:My friend Jer...
                            
                            
                                分类:
其他好文   时间:
2014-07-25 03:19:37   
                                阅读次数:
201
                             
                    
                        
                            
                            
                                C++中的友元机制允许类的非公有成员被一个类或者函数访问,友元按类型分为三种:普通非类成员函数作为友元,类的成员函数作为友元,类作为友元。
1 友元的内容
友元包括友元的声明以及友元的定义。友元的声明默认为了extern,就是说友元类或者友元函数的作用域已经扩展到了包含该类定义的作用域,所以即便我们在类的内部定义友元函数也是没有关系的。
2 普通的非成员函数友元
这类友元函数通常是操作符,...
                            
                            
                                分类:
编程语言   时间:
2014-07-23 13:37:47   
                                阅读次数:
354