STL 源码剖析

临时对象的产生与运用

#include <stdio.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

template <typename T>
class print {
public:
	void operator()(const T& elem)
	{
		cout << elem << " ";
	}
};

int main()
{
	int ia[6] = { 0,1,2,3,4,5 };
	vector<int> iv(ia, ia + 6);

	for_each(iv.begin(), iv.end(), print<int>());
}

临时对象,就是一种无名对象。

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-16 19:00:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-16 19:00:03       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-16 19:00:03       82 阅读
  4. Python语言-面向对象

    2023-12-16 19:00:03       91 阅读

热门阅读

  1. js 原型 和 原型链

    2023-12-16 19:00:03       60 阅读
  2. CoPilot究竟如何使用?

    2023-12-16 19:00:03       62 阅读
  3. PostgreSQL DBA之数据库指标监控

    2023-12-16 19:00:03       50 阅读
  4. go context.todo生成默认空的上下文

    2023-12-16 19:00:03       42 阅读
  5. 如何判断服务器能容纳多少人同时访问

    2023-12-16 19:00:03       43 阅读
  6. Js WebSocket类,收发Json,带心跳,断线重连

    2023-12-16 19:00:03       51 阅读
  7. 动态规划算法解决背包问题(Python)

    2023-12-16 19:00:03       56 阅读
  8. 软件测试计划文档

    2023-12-16 19:00:03       58 阅读
  9. JVM源码剖析之registerNatives方法

    2023-12-16 19:00:03       55 阅读