Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 02-19-2004, 02:50 PM   #1 (permalink)
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  
Old 02-19-2004, 06:38 PM   #2 (permalink)
Junkie
 
Location: San Francisco
Re: c++ use of class template as an expression?

Quote:
Originally posted by strcrssd
template<typename kind>
kind visVector<kind>::operator[](int index){
return vector::at(index);
}
has to be
return vector<kind>::at(index);
n0nsensical is offline  
 

Tags
class, expression, template


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 09:15 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

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