mercredi 18 mars 2015

Why is Koening lookup not working here?


Argument dependent lookup says:



For arguments of class type (including union), the set consists of... a) The class itself b)...



Then why can't printX find X?



#include<iostream>
using namespace std;

class A {
public:
static const int X = 1;
};

class B {
public:
static void printX(A a)
{
cout << "X is " << X << endl;
}
};

int main(int argc, char** argv)
{
A a;
B::printX(a);
return 0;
}



Aucun commentaire:

Enregistrer un commentaire