2.2.3.18.1 vector::Add

Description

Adds One element at the end of the vector.

Syntax

int Add( _TemplType element )

Parameters

element
[input] The element to be added to this vector. _TemplType type is an implicit templatized type, which is the type of one element of this vector. The types of vector supported are char, byte, short, word, int, uint, double, complex, string.

Return

The index of the added element.

Examples

EX1

//Add double data to double vector. 
void vector_Add_ex1()
{
    vector<double> vD = {1.1, 2.2};
    double d = (3.999); 
    vD.Add(d);
 
    for(int ii = 0; ii < vD.GetSize(); ii++)
    {
        printf("vD[%d]= %f\n", ii, vD[ii]);
    }
}

EX2

//Add string to string vector. 
void vector_Add_ex2()
{
    vector<string> vsExt = {"OPJ", "TXT"};
    vsExt.Add("SPC");

    for(int ii = 0; ii < vsExt.GetSize(); ii++)
    {
        printf("Extesion(%d) : %s\n", ii, vsExt[ii]);
    }
}

EX3

//Add complex to complex vector
void vector_Add_ex3()
{
    vector<complex> vC;
    complex cc(4.3, 5.6);

    vC.Add(cc);			//Add cc to vC 
    for(int ii = 0; ii < vC.GetSize(); ii++)
    	out_complex("value=", vC[ii]);
}

Remark

See Also

vector::InsertAt

Header to Include

origin.h