摘要: 1、友元的声明只能出现在类定义的内部,2、可以出现在类中的任何地方,3、友元不是类的成员函数!所以它的声明可以出现在类中任何地方,而不受声明前面的访问控制影响!以上几条可见下例子:#include <iostream>using namespace std;class TestPoint {private: int x; int y; friend int distanceOne(); //友元的声明可以出现在类内任何地方,它不是类的成员函数!public: friend int distanceTwo(); //友元的声明可以出现在类内任何地方,它不是类的成员函数!};int d 阅读全文
posted @ 2012-12-25 20:43 helloweworld 阅读(901) 评论(0) 推荐(0) 编辑
摘要: 这里重点介绍?: #include <iostream>using namespace std;int main(void){ int a = 2; int b = 3; a > b ? a++ : b++; cout << a << endl; cout << b << endl; return 0;}输出:24这里a>b为假,则直接执行b++,不执行a++. 阅读全文
posted @ 2012-12-25 18:40 helloweworld 阅读(184) 评论(0) 推荐(0) 编辑