C++ Logo

std-discussion

Advanced search

Question about name lookup and class member?

From: Eric Suen <eric_suen_at_[hidden]>
Date: Mon, 7 Jun 2021 00:57:34 +0800
The following code, how do parser know that V is template and B is not?

struct A {
   int a = V<1>();
   bool b = B < 0;

   void print() {
     std::cout << a;
   }

   template<int v>
   static int V() {
     return v;
   }

   static int B;
};

int A::B = 1;

int main() {
   A a;
   a.print();
}

Received on 2021-06-06 11:57:44