1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 11 using std::cout; 12 using...
分类:
其他好文 时间:
2014-07-26 00:27:36
阅读次数:
252
不存在指向空值的引用这个事实意味着使用引用的代码效率比使用指针的要高,因为在使用引用之前不需要测试它的合法性:1 void printDouble(const double& rd) 2 { 3 cout << rd; // 不需要测试rd,它肯定指向一个double值 4 } 相反,指针...
分类:
其他好文 时间:
2014-07-25 02:15:44
阅读次数:
172
1 //b.cpp 2 3 #inlcude 4 5 void b() 6 { 7 std::cout<<"fun b"; 8 } 9 10 //a.cpp11 extern void b();12 13 int main()14 {15 b();16 return ...
分类:
编程语言 时间:
2014-07-24 12:12:05
阅读次数:
241
#include
#include
#include
using namespace std;
int main(){
ifstream in("E:\\read.txt");
string s;
int t=0,j,start;
int i=0;
while(getline(in,s)){
//cout<<s<<endl;
// t++;
for(j=...
分类:
其他好文 时间:
2014-07-24 10:37:01
阅读次数:
390
#include #include//get namespace related stuff using std::cin; using std::cout; using std::endl; using std::flush; using std::string; using std::vecto...
分类:
编程语言 时间:
2014-07-23 22:12:17
阅读次数:
350
#include // std::cout, std::boolalpha, std::noboolalphaint main () { bool b = true; std::cout << std::boolalpha << b << '\n'; //把bool表示为alpha...
分类:
编程语言 时间:
2014-07-23 22:10:27
阅读次数:
178
1.main函数可以递归吗?g++,vs2010是可以的2.int main(){ static int a=5; while(--a > 0){ cout 0){ cout << "before" << a << endl; main(); cout << "after" << a << end....
分类:
其他好文 时间:
2014-07-23 16:45:51
阅读次数:
204
面向对象编程概述
继承(Inheritance)
class Quote
{
public:
Quote(){cout<<"Quote的构造函数!"<<endl;}
string isbn() const {cout<<"Quote的isbn()调用!"<<endl; string s="Quote,isbn"; return s;}
virtual double ...
分类:
编程语言 时间:
2014-07-23 13:18:16
阅读次数:
314
在C++中cout的输出流当中,有一些问题很容易出错,就比如下面这道简单程序,看似简单,但却是一个值得深思的问题~~
#include
using namespace std;
int foo(int &x)
{
cout
return ++x;
}
int main()
{
int i = 1;...
分类:
其他好文 时间:
2014-07-23 13:04:36
阅读次数:
231
#include
#include
using namespace std;
queueq;
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
q.push(i);
while(!q.empty())
{
cout<<q.front()<<' ';
q.pop();
if(!q.empty())
...
分类:
其他好文 时间:
2014-07-22 22:34:33
阅读次数:
179