list7-2.cpp

来自「这是关于VC++中的STL容器的资料,包括了STL容器各个类之间关系以及类的说明」· C++ 代码 · 共 20 行

CPP
20
字号
// Listing 7.2 demonstrates how a constructor can be used to initialize a container
// with a certain number of objects initialized to a specific value.

#include <list>
#include <iostream>

using namespace std;

void main(void)
{
    list<double>  Sequence(10,1812.23);
    list<double>::const_iterator N = Sequence.begin();
    int Count = Sequence.size();
    while(Count)
    {
      	cout <<  "List Element " << Count << " : " << *N << endl;
      	Count--;
      	N++;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?