Problem with a member function of a class - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Programming with C++ (https://www.supportforums.net/forumdisplay.php?fid=20) +---- Thread: Problem with a member function of a class (/showthread.php?tid=2330) |
Problem with a member function of a class - charnet3d - 10-29-2009 Hi everybody, I have been assigned a homework in C++, in which I have to create a class vector3d. Here's my code: Code: #include <iostream> I don't know what's wrong with it, it gives me the error "invalid use of member (did you forget the `&' ?)" in the first line "if (this->norm() > v.norm())" inside the member function norm_compare. When I take away "v.norm" and replace it with a 0 it doesn't give the error, I don't understand, because that's supposed to work! Thanks in advance for your help ^^ RE: Problem with a member function of a class - Gaijin - 10-29-2009 Well "norm" is a function and you forgot "()". Code: if (this->norm() > v.norm) That complied on my pc with dev-c++. RE: Problem with a member function of a class - charnet3d - 10-31-2009 ohhh what a mistake!! Such subtleties make you go crazy, and the compiler notifies you about something far bigger hehe Really thank very much, that saved me a lot of pain ^^ |