wcvt22.cpp

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C++ 代码 · 共 29 行

CPP
29
字号
#include <wcvector.h>
#include <iostream.h>
#include "strdata.h"
#include "testexpt.h"

int main() {
    WCValOrderedVector<str_data> vect;
    str_data first( "First" );
    str_data negative( "Negative" );
    str_data too_high( "Too high" );

    vect.insertAt( 5, first );
    cout << "Number of entries "  << vect.entries() << "\n";
    vect.insertAt( -100, negative );
    vect.insertAt( 1000, too_high );
    cout << "Vector elements (should be \"Negative  First  Too high\"\n";
    for( int i = 0; i < vect.entries(); i++ ) {
	cout << vect[ i ] << "  ";
    }
    cout << "\n";

    vect.exceptions( WCExcept::index_range );
    vect.insertAt( vect.entries(), too_high );
    vect.insertAt( 0, negative );
    test_except( vect.insertAt( vect.entries() + 1, too_high ), index_range, "too high" );
    test_except( vect.insertAt( -1, negative ), index_range, "-1" );
    return 0;
}

⌨️ 快捷键说明

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