S
Sean J. Fraley
This code illustrates what I'm confused about:
template<typename T>
class foo
{
public:
template<typename U>
void
fooFunction(const foo<U>& x)
{
if(this != &x) //<=== where the problem apparently is.
cout << "yipee!!\n";
}
};
int main()
{
foo<int> x;
foo<float> y;
x.fooFunction(y); // instantiated from here.
return EXIT_SUCCESS;
}
testingg.cpp:38: error: comparison between distinct pointer types
`foo<int>*' and `const foo<float>*' lacks a cast
Why can't I compare the addresses of the two class instances? I'm not
dereferencing the pointers, I'm just making sure that the instance passed
as a parameter to fooFunction is not the same instance that fooFuntion is
being called on.
Is this something that is supposed to happen, or is this just a compiler
issue(gcc 3.3.3).
Thank you
Sean J. Fraley
template<typename T>
class foo
{
public:
template<typename U>
void
fooFunction(const foo<U>& x)
{
if(this != &x) //<=== where the problem apparently is.
cout << "yipee!!\n";
}
};
int main()
{
foo<int> x;
foo<float> y;
x.fooFunction(y); // instantiated from here.
return EXIT_SUCCESS;
}
testingg.cpp:38: error: comparison between distinct pointer types
`foo<int>*' and `const foo<float>*' lacks a cast
Why can't I compare the addresses of the two class instances? I'm not
dereferencing the pointers, I'm just making sure that the instance passed
as a parameter to fooFunction is not the same instance that fooFuntion is
being called on.
Is this something that is supposed to happen, or is this just a compiler
issue(gcc 3.3.3).
Thank you
Sean J. Fraley