#include "stdafx.h"#include using namespace std;int _tmain(int argc, _TCHAR* argv[]){ cout << endl << "关于数组的问题" <<endl; int a[] = {1, 2, 3, 4, ...
分类:
其他好文 时间:
2014-07-22 22:47:55
阅读次数:
196
避免含糊转换
参数匹配和相互转换
struct B;
struct A
{
A()=default;
A(const B&) //吧B负责给A,拷贝构造函数
{//嘿,这里我有点明白了,只要 后面调用了这个函数,那么这个函数就得有定义
//不能只声明不定义
cout<<"调用了A(const B&)转换!"<<endl;
}...
分类:
编程语言 时间:
2014-07-22 14:43:26
阅读次数:
297
#include?<iostream>
#include?<algorithm>
using?namespace?std;
//回调函数
void?call_back(char?elem)
{
?cout?<<?elem?<<?endl;
}
//仿函数
struct?Functor
{
?void?operator()?(char?elem)...
分类:
其他好文 时间:
2014-07-22 08:13:37
阅读次数:
316
shared_ptr智能指针的意思即:boost::shared_ptr是可以智能的管理动态分配的内存资源,几个智能指针可以同时共享一个动态分配的内存的所有权。
下面我们通过一个例子来学习一下它的用法:
注 :使用shared_ptr智能指针,要加入#include 头文件
class example
{
public:
~example() { std::cout "...
分类:
其他好文 时间:
2014-07-21 22:43:47
阅读次数:
297
以下例子中,存储了整数123的记亿体空间不能被删除,因为地址丢失了。这些空间已无法再使用。 1 #include 2 using namespace std; 3 int main() 4 { 5 int *a = new int(123); 6 cout 2 #include...
分类:
编程语言 时间:
2014-07-21 09:38:20
阅读次数:
224
#include #include #include using std::cout;class Grand{ private: int hold; public: Grand(int h=0):hold(h){} virtual void Speak() const {cout Speak(...
分类:
其他好文 时间:
2014-07-21 09:12:31
阅读次数:
232
描述输入两个自然数,输出他们的和格式输入格式两个自然数x和y (0using namespace std;int main(){ int a,b; cin>>a>>b; cout<<(a+b)<<endl; return 0;}
分类:
其他好文 时间:
2014-07-21 00:25:43
阅读次数:
182
1 #include 2 #include 3 #include 4 #include 5 6 using std::cout; 7 class Grand 8 { 9 private:10 int hold;11 public:12 Gr...
分类:
其他好文 时间:
2014-07-20 21:38:39
阅读次数:
353
#includeusing namespacestd;intmain(){ intn,x,y; while(cin>>n,n) { cin>>x; while(--n) { cin>>y; x=x^y; } cout<<x<<"\n"; } return0;}
分类:
其他好文 时间:
2014-07-20 21:30:54
阅读次数:
230
函数引用操作符
struct absInt
{
int operator()(int val) const
{
cout!!!"<<endl;
return val<0 ? -val : val;
}
};
void fun1()
{
int i=-42;
absInt absObj;
int ui=absObj...
分类:
编程语言 时间:
2014-07-20 10:32:09
阅读次数:
380