Why does this say shaddowing? If I change my member X and Y to _X, _Y then when I access my class via the dot operator, it shows FOUR values..

Current Class:

class Point
{
    public:
        int X, Y;

    Point(int X, int Y);
    ~Point();
};

Point::Point(int X, int Y) : X(X), Y(Y) {}

Previous class that shows x, y, X, Y:

class Point
{
    public:
        int Y, Y;

    Point(int x, int y);
    ~Point();
};

Point::Point(int x, int y) : X(x), Y(y) {}

How can I stop the compiler from telling me it's shaddowing but at the same time only have the class members show in my intellisense instead of both class and function members?

Codeblocks and VS2010 and VS2012 RC do this :S

Also why should I include <complex> to use std::abs instead of including math.h and using fabs?

I'm trying to compare floating point values using:

#define VERYSMALL  (1.0E-150)
#define EPSILON    (1.0E-8)

bool Extended::Equal(double a, double b)
{
    double absDiff = std::abs(a - b);
    if (absDiff < VERYSMALL)
        return true;

    double maxAbs  = max(std::abs(a), std::abs(b));
    return (absDiff/maxAbs) < EPSILON;
}

Why does this say shaddowing?

Because your data members have the same name as your parameters. Whenever this happens, the compiler will always assume that when you refer to that variable name, you mean the variable with the most local scope, in this case, it would be the function parameters. You should never use the same names for the parameters and data members. My trick is to simply add an "a" in front of the parameter names (some people also use a trailing underscore). As so:

Point::Point(int aX, int aY) : X(aX), Y(aY) {}
// or:
Point::Point(int X_, int Y_) : X(X_), Y(Y_) {}

The compiler says it "shaddows" the data members because when you use those names, it won't refer to the data members, i.e., the parameters hide the data members.

Also why should I include <complex> to use std::abs instead of including math.h and using fabs?

Because "math.h" is not a standard C++ header. You should always use <cmath>. As for the absolute function(s), the C++ standard cmath header contains all the same functions as the C standard "math.h" header, but they are in the std namespace. And thanks to C++ overloading, the fabs and abs functions are the same (as opposed to C, in which fabs is for floats and abs is for integers). You can use either one of the absolute-value functions std::fabs or std::abs, they are the same (and overloaded for all types).

Comments
Did not know about CMath :D Thank you

Ahh Thanks for the info. I had to ask because I was taught that this->X = X will fix the shaddowing so I went and changed all my classes to "Shaddow" and after reading your post I had to change them back.

Then I enabled all warnings on codeblocks and it complained until it couldn't complain anymore. Just fixed it Thank you.

This question has already been answered. Start a new discussion instead.