Quote:
Original post by westond
I know what I want to do, but unfortunately I dont know how to convey it.
That much is normal. [smile]
Quote:
This works and compiles fine... but I want a pointer to the Objv vector.
See, the resistance that I perceive is in terms of "wanting" something that I can tell you (from my years of experience) is more complex and doesn't accomplish anything extra. :
Quote:
I tried this below, but the word=Objv[i]->Getchar() and Getid() break and want a "." instead.
*** Source Snippet Removed ***
Currently, you index into the vector, yielding an Object*; then you can use -> to dereference the Object* to get an Object, and select its Getchar() member function.
If you have a pointer to the vector, then 'Objv[i]' is no longer indexing into the vector, but instead operating upon the pointer - i.e. assuming you have an array of some kind (in particular, an array of vectors). That selects a vector, so you can't use -gt;Getchar() at that point - first off because that tries to do a dereference (and you don't have a pointer), and secondly because the *vector* doesn't have a Getchar(). Although the compiler is generally very smart about the code that it writes when it gets a correct program, it's usually very dumb about how it reports errors - it basically reads one "token" at a time and reports the error as soon as it knows there is one, using only the information it has so far (even if the very next token could give it a much better understanding of what you're really trying to do). That's why it tells you it wants a '.': the only thing it sees for the time being is a -> applied to a non-pointer.
What you would need to do is dereference the pointer first (to get the vector) and *then* index in. That looks like (*Objv)[i]->Getchar().
... You see? More complicated, and it won't work any better: the whole point of using the vector in the first place is to let *it* manage the dynamic allocation.
Quote:
Also, cin and cout will not work unless i #include <iostream>... but I thought iostream was included in fstream. What did I miss there? Even dropped the using namespace and tried std::cin..etc
It is not (necessarily - it could on someone else's implementation, because the person putting that implementation together found it made his/her life easier to do so, but you should not rely on that), because cin and cout aren't file streams - they're console streams. :)