开发者

Are there linked lists in Ul++?

Are ther开发者_如何学Goe linked list in NTL or somewhere in Ultimate IDE? I guess there is not but correct me if I am wrong.


Just about every compiler that reasonably conforms to the C++ standard provides a standard libary implementation, which includes linked lists.

You're looking for std::list (a doubly-linked list implementation in C++), which is located in the <list> header.

Example:

#include <list>

int main()
{
    std::list<int> numbers;

    numbers.push_back(1);
    numbers.push_back(2);
    numbers.push_back(3);
    numbers.push_back(4);
    numbers.push_back(5);

    for(std::list<int>::iterator i = numbers.begin();
        i != numbers.end(); ++i)
    {
        // Do something with each element.
        // Each element can be accessed by dereferencing i.
        // For example:
        int number = *i;
    }

    return 0;
}

Nitpick: The Ultimate++ IDE is simply a graphical front-end for a C++ compiler - the IDE has no bearing on the availability of libraries.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜