Im trying to make a class that can hold of the position of something(its x,y,z coords).
I want it to be able to work with any kind of number so i thought id be easy with some typenaming templates for my fuctions and the private variables.
i keep getting:
data member ‘x’ cannot be a member template
data member ‘y’ cannot be a member template
data member ‘z’ cannot be a member template
Im guessing im going about this wrong. Heres the code id like to make more generic. Any advice?
Code:
#ifndef __POSITION_H_
#define __POSITION_H_
#include <iostream>
using namespace std;
class position {
public:
position(int X=0, int Y=0, int Z=0) {
set(X, Y, Z);
}
//
// Set position
//
void setX(int X) {
x = X;
}
void setY(int Y) {
y = Y;
}
void setZ(int Z) {
z = Z;
}
void set(int X, int Y, int Z) {
setX(X);
setY(Y);
setZ(Z);
}
//
// Get position
//
int getX() {
return x;
}
int getY() {
return y;
}
int getZ() {
return z;
}
private:
int x;
int y;
int z;
};
#endif
Thanks