View Single Post
Old 02-19-2004, 02:50 PM   #1 (permalink)
strcrssd
Insane
 
Location: Rio Grande Valley, Texas
c++ use of class template as an expression?

I'm lost as to what is wrong here, can anyone give me a hand?

Code:
#include <vector>
using namespace std;

template<typename kind>class visVector:public vector<kind>{
    public:
        visVector(int basex, int basey);
        kind operator[](int index);
        kind at(int loc);
        void push_back(kind);
    private:
        int bx, by;
};

template<typename kind>
visVector<kind>::visVector(int basex, int basey){
    bx = basex;
    by = basey;
}
    
template<typename kind>
kind visVector<kind>::operator[](int index){ 
    return vector::at(index);
} 

template<typename kind>
kind visVector<kind>::at(int index){
    return vector::at(index);
}

template<typename kind>
void visVector<kind>::push_back(kind toBeAdded){
    //need to locate where we're pushing onto, then highlight that section
    vector::push_back(toBeAdded)
}

int main(int argc, char* argv){
    visVector<int> v;
    for(int i = 0; i < 10; i++)
        v.push_back(i);
    for(int i = 0; i < v.size(); i++)
        cout << v[i] << ", ";
        cout << endl;
    for(int i = 0; i < v.size(); i++)
        v[i] = v[i] * 10; // Assignment  
    for(int i = 0; i < v.size(); i++)
        cout << v[i] << ", ";
        cout << endl;
}
I'm getting the error code in g++:

Quote:
visVector.cpp: In member function `kind visVector<kind>:perator[](int)':
visVector.cpp:22: error: use of class template `template<class _Tp, class
_Alloc> class std::vector' as expression
I have no idea what this means. Anyone?

Thanks
__________________
"I can't understand why people are frightened of new ideas. I'm frightened of the old ones." -- John Cage (1912 - 1992)
strcrssd is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73