指向list 的指针 list<int> *pmylist = new list<int> [2];
2011-10-18 22:45
465 查看
// testList.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#include<string>
#include <list>
using namespace std;
void myfun(list<int> *pmylist)
{
pmylist[0].push_back(300);
pmylist[1].push_back(311);
int i = 0;
for ( list < int > :: iterator it = pmylist[0].begin () ; it != pmylist[0].end (); it ++ )
{
printf( "pmylist[0](%d) = %d\n",i,(*it));
i ++;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
list <int> mylist;
mylist.push_back(1);
mylist.push_back(2);
int i = 0;
for ( list < int > :: iterator it = mylist.begin () ; it != mylist.end (); it ++ )
{
printf( "mylist(%d) = %d\n",i,(*it));
i ++;
}
printf("\n");
list <int> mylist2[2];
mylist2[0].push_back(20);
mylist2[0].push_back(200);
mylist2[1].push_back(21);
printf( "mylist2[0] = %d\n",(*mylist2[0].begin()));
printf( "&mylist2[1] = %d\n",mylist2[1].begin());
list<int> *pmylist = new list<int> [2];
pmylist[0].push_back(30);
pmylist[1].push_back(31);
printf( "pmylist[0] = %d\n",(* pmylist[0].begin()));
myfun(pmylist);
myfun(mylist2);
delete []pmylist;
return 0;
}
相关文章推荐
- C++ error C2662: “LinkNode<T> *List<T>::Locate(int)”: 不能将“this”指针从“const List<int>”转换为“List<int> &”
- List<?> list= new ArrayList<?>为什么这样写 接口引用指向实现类的对象
- ArrayList<Integer> list = new ArrayList<Integer>();在这个泛型为 Integer 的 ArrayList 中存放一个 String 类型的对象。
- 请问一下在java中的List<int> list=new List<int>();这条语句的两个int处会报错,请问为什么?
- Map<String, List> map=new HashMap<String,List>()
- error: 函数调用缺少参数列表;请使用“&BinTree<char>::_PrintNode”创建指向成员的指针
- How to cast List<Object> to List<MyClass> Object集合转换成实体集合
- 不能将参数 1 从“int”转换为“std::_Vector_const_iterator<_Myvec>”(VS2010 )
- 工作总结 a标签 <a href="/meetingtheme">Back to List</a> 返回上一级 指向 控制器 默认Index @Html.ActionLink("Edit59", "Edit", new { id = item.ID }) 默认当前控制器
- MVC后台返回List<int>ViewData, 前台接受
- 写一个MyList<T>的类,内部用T[]实现(不能使用系统的List<T>类),需要实现的接口如下:
- C# 获得List<int>众数
- List<T>集合排序与Dictionary<int,string>排序
- LNK2019: 无法解析的外部符号 "public: void __thiscall List<int>::add(int const &)" (?add@?$List@H@@QAEXABH@Z),
- ArrayList list = new ArrayList() 和List<String> list = new ArrayList<String>() 的区别?
- public void Delete<T>(List<T> EntityList) where T : class, new()
- return null 与return new List<HaierPageView>()的区别
- Java 中的 int 与 Integer 用于 List<Integer> 时,以及通过打印变量检测程序运行和函数调用次数计数
- Java 中的 int 与 Integer 用于 List<Integer> 时,以及通过打印变量检測程序执行和函数调用次数计数
- List<Person> persons=new ArrayList<Person>();