hi all,
I am currently trying to write a code that involves appending a value to the end of a vector, but i am having trouble.
It will compile and run okay without any errors, but for some reasons, array.pushback(a) won't change my object. I've also tried overloading operator[], but to no avail.Code:TextNumerical TextLiteral::convertToTextNum() { TextNumerical array; for ( int i=0; i<getLength(); i++ ) { if ( !isLetter ( text[i] ) ) { continue; } UINT a = (UINT) text[i] - 65; array.push_back ( a ); } return array; } class TextNumerical { // TextNumerical is a structure with two arrays -- an input // and an output.The data has been converted into numbers // for encoding and decoding. private: std::vector<UINT> input; std::vector<UINT> output; public: TextNumerical() {}; TextNumerical( std::vector<UINT> ); void push_back ( const UINT& val ) { output.push_back ( val ); } std::vector<UINT> getOutput() const { return output; } std::vector<UINT> getInput() const { return input; } int getSize() const { return input.size(); } void reserve( std::string::size_type size ) { output.reserve( size ); } void printOutput() const; std::string convertToText() const; };
Any ideas?