当前位置: 首页>>代码示例>>C++>>正文


C++ XList::push_back方法代码示例

本文整理汇总了C++中XList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ XList::push_back方法的具体用法?C++ XList::push_back怎么用?C++ XList::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XList的用法示例。


在下文中一共展示了XList::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	XList<int> list;
	XList<int>::iterator it;
	XList<int>::reverse_iterator rit;
	
	list.push_back(11);
	list.push_front(8);
	list.push_back(12);
	list.push_back(13);
	list.push_back(14);

	list.print();
	std::cout<<list.size()<<std::endl;

	it = list.begin();
	std::cout<<*(++it)<<std::endl;

	for (it = list.begin(); it != list.end(); ++it)
		std::cout<<*it<<" ";
	std::cout<<std::endl;

	for (rit = list.rbegin(); rit != list.rend(); ++rit)
		std::cout<<*rit<<" ";
	std::cout<<std::endl;

	it = list.end();

	return 0;
}
开发者ID:Eldar7,项目名称:OOPcpp,代码行数:30,代码来源:main.cpp

示例2: main

int main(){
    XList<Shape*> shapes;
    Point * point1 = new Point(0., 2., "point_1");
    shapes.push_back(point1);
    Point * point2 = new Point(2., 2., "point_2");
    shapes.push_back(point2);
    Point * point3 = new Point(2., 0., "point_3");
    shapes.push_back(point3);
    Point * point4 = new Point(0., 0., "point_4");
    shapes.push_back(point4);

    Circle * circle = new Circle(point4, 10., "circle_1");
    shapes.push_back(circle);

    Rect * rect = new Rect(point1, point2, point3, point4, "rectangle");
    shapes.push_back(rect);

    try {
        Square * square = new Square(point1, point2, point3, point4, "square");
        shapes.push_back(square);
    } catch (const char* error){
        // std::cout << "EXCEPTION RAISED: " << error << std::endl;
    }


    Polyline * polyline = new Polyline("polyline");
    polyline->AddPoint(point1);
    polyline->AddPoint(point2);
    polyline->AddPoint(point3);
    polyline->AddPoint(point4);
    shapes.push_back(polyline);

    for (XList<Shape*>::iterator it = shapes.begin(); it != NULL; ++it) {
        std::cout << *it;
    }
    printf("Number of shapes = %d\n", Shape::GetCount());
    for (XList<Shape*>::iterator it = shapes.begin(); it != NULL; ++it) {
        delete *it;
    }
    printf("Number of shapes = %d\n", Shape::GetCount());
    return 0;
}
开发者ID:kakty3,项目名称:kostov-oop,代码行数:42,代码来源:main.cpp


注:本文中的XList::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。