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; } Quote:
Thanks
__________________
"I can't understand why people are frightened of new ideas. I'm frightened of the old ones." -- John Cage (1912 - 1992) |
|
Tags |
class, expression, template |
|
|