Why does this code segment
generate these errors when compiled via the Terminal (using g++) (user name **'d)
I correctly #included "apvector.h" and "apstring.h" at the beginning, so I'm at a loss as to what's wrong.
Also, I have one other question, but I'll save it until later.
EDIT:
here's the syntax for apvector's use
based on this constructor code
That all may help. Any ideas?
Code:
apvector<apstring> GetWords() // opens dictionary, reads words into a vector
{
ifstream fin("dictionary.txt")
apvector<apstring> vocab(0);
int counter = 0;
while (!fin.eof())
{
counter++;
getline(fin, vocab[counter-1]);
vocab.resize(counter);
}
fin.close();
return vocab;
}
Code:
/Users/**/Documents/AP Comp Sci Docs/Monkies.cpp: In function
`apvector<apstring> GetWords()':
/Users/**/Documents/AP Comp Sci Docs/Monkies.cpp:54: parse error before `
<' token
/Users/**/Documents/AP Comp Sci Docs/Monkies.cpp:59: `vocab' undeclared
(first use this function)
/Users/**/Documents/AP Comp Sci Docs/Monkies.cpp:59: (Each undeclared
identifier is reported only once for each function it appears in.)
Also, I have one other question, but I'll save it until later.
EDIT:
here's the syntax for apvector's use
Code:
// examples of use
// apvector<int> v1; // 0-element vector
// apvector<int> v2(4); // 4-element vector
// apvector<int> v3(4, 22); // 4-element vector, all elements == 22.
based on this constructor code
Code:
template <class itemType>
class apvector
{
public:
// constructors/destructor
apvector( ); // default constructor (size==0)
explicit apvector( int size ); // initial size of vector is size
apvector( int size, const itemType & fillValue ); // all entries == fillValue
apvector( const apvector & vec ); // copy constructor
~apvector( );
That all may help. Any ideas?