I wrote a little C++ class to implement the parsing of text into matrices. I works pretty well except that I cant seem to access the string vector that holds the numeric data as strings. It doesnt make sense to me because I can demonstrate that in at least one function of the class, the string vector is properly initialized. But when I try to acces it in another class function (the retrieval function), the vector has size = 0.
Heres some pseudo-code to further explain my dilemma:
The problem here is that the member vector, m_vs gets properly initialized in the CLex:arse function, but when I try to use CLex::get_svec() to access the data, it comes up empty. Checking the value(s) of m_vs in the function get_svec, m_vs is empty. So what happened to it?
Code:
#include "lex.h"
int main()
{
string s;
vector<string> vs;
CLex lx;
s = "1 2 3\r\n4 5 6\r\n";
lx.parse(s);
vs = lx.get_svec() ;
cout << vs[0] << endl;
}
The class member vector, m_vs, will have values of "1", "2", "3", "4", "5", "6" within the CLex:arse() function, but will be empty (have zero size) in the CLex::get_svec() function.
Can anyone show me what I am doing wrong here? I'm sure it's something fairly simple and stupid as usual.
Thanks.
Mike
Last edited by Mike Pliam; December 12th, 2003 at 01:00 PM.
Bookmarks