P
Preben
Hi everyone
Could you help me with these erorrs:
-----------
rotX.cpp: In member function 'void AO_Sphere::draw()':
rotX.cpp:32: error: 'rotX' was not declared in this scope
rotX.cpp:33: error: no match for 'operator*' in '-0x000000001 *
orientierung'
-----------
and one of the errors is also pointed out by icc:
-----------
rotX.cpp(33): error: no operator "*" matches these operands
operand types are: int * KMatrix<double>
orientierung = -1*orientierung;
^
compilation aborted for rotX.cpp (code 2)
-----------
And the code is as follows:
-----------
#define PI 3.14159265358979323846
template<class Tcomp> class KMatrix;
template<class Tcomp> KMatrix<Tcomp> operator* (const Tcomp r, const
KMatrix<Tcomp>&);
template<class Tcomp> class KMatrix {
public:
KMatrix();
KMatrix(int rows, int cols); /** KMatrix of dimension rows x cols */
KMatrix(const KMatrix<Tcomp>&);
~KMatrix();
const KMatrix<Tcomp>&
operator -= (const KMatrix<Tcomp>&);
/** * scalar multiplication */
friend KMatrix<Tcomp> operator * <>(const Tcomp r, const
KMatrix<Tcomp> &m);
/** * generate rotation matrices about x,y,z-axes */
friend KMatrix<double> rotX(double angle);
};
class AO_Sphere {
public:
void draw();
};
void AO_Sphere::draw() {
KMatrix<double> orientierung;
orientierung = rotX(double(2*PI)/double(1));
orientierung = -1*orientierung;
}
-----------
The first problem is that the rotX method isn't found. How come that
this is the case. It is defined as a friend method? Is the syntax not
correct? How to alter?
The next problem could actually easily be solved by replacing a "-1."
instead of "-1" in the second-last line. But however for code
maintenance this is a bad idea.
How can I let the compiler accept the code by casting the -1 to a double
automatically.
As far as I know, any function on a template should automatically cast
to the given value if an implicit constructor is given. Since this is
int and double there shouldn't be such a problem, or?
Thanks
/ Preben
Could you help me with these erorrs:
-----------
rotX.cpp: In member function 'void AO_Sphere::draw()':
rotX.cpp:32: error: 'rotX' was not declared in this scope
rotX.cpp:33: error: no match for 'operator*' in '-0x000000001 *
orientierung'
-----------
and one of the errors is also pointed out by icc:
-----------
rotX.cpp(33): error: no operator "*" matches these operands
operand types are: int * KMatrix<double>
orientierung = -1*orientierung;
^
compilation aborted for rotX.cpp (code 2)
-----------
And the code is as follows:
-----------
#define PI 3.14159265358979323846
template<class Tcomp> class KMatrix;
template<class Tcomp> KMatrix<Tcomp> operator* (const Tcomp r, const
KMatrix<Tcomp>&);
template<class Tcomp> class KMatrix {
public:
KMatrix();
KMatrix(int rows, int cols); /** KMatrix of dimension rows x cols */
KMatrix(const KMatrix<Tcomp>&);
~KMatrix();
const KMatrix<Tcomp>&
operator -= (const KMatrix<Tcomp>&);
/** * scalar multiplication */
friend KMatrix<Tcomp> operator * <>(const Tcomp r, const
KMatrix<Tcomp> &m);
/** * generate rotation matrices about x,y,z-axes */
friend KMatrix<double> rotX(double angle);
};
class AO_Sphere {
public:
void draw();
};
void AO_Sphere::draw() {
KMatrix<double> orientierung;
orientierung = rotX(double(2*PI)/double(1));
orientierung = -1*orientierung;
}
-----------
The first problem is that the rotX method isn't found. How come that
this is the case. It is defined as a friend method? Is the syntax not
correct? How to alter?
The next problem could actually easily be solved by replacing a "-1."
instead of "-1" in the second-last line. But however for code
maintenance this is a bad idea.
How can I let the compiler accept the code by casting the -1 to a double
automatically.
As far as I know, any function on a template should automatically cast
to the given value if an implicit constructor is given. Since this is
int and double there shouldn't be such a problem, or?
Thanks
/ Preben