0

The following code compiles fine in Visual Studio 2015. In Visual Studio 2022, I get an error "'Foo': identifier not found" inside NestedEdge::Bar.

Changing Foo(); to BaseEdgeType::Foo(); inside NestedEdge::Bar solves the issue.

How can I access members of the base class without explicitly specifying the base class in Visual Studio 2022?

class Edge {
public:
    auto Foo() const -> void {}
};

template<class BaseEdgeType>
class NestedEdge : public BaseEdgeType {
public:
    auto Bar() const -> void {
        Foo();
    }
};

class MyEdge : public NestedEdge<Edge> {};
Magnar Myrtveit
  • 2,432
  • 3
  • 30
  • 51
  • 1
    Another option is `this->Foo();` – Eljay Mar 02 '22 at 14:20
  • You cannot just use the name of the member. You need to qualify it in one of the ways mentioned above. This was always the case, however MSVC did not follow the standard in regards to this in previous versions when not in conformance mode. You can probably get back the old MSVC behavior by explicitly disabling the standard-conformance mode with the `/permissive` flag, but I would recomment fixing your program to be standard-conform instead. – user17732522 Mar 02 '22 at 14:23
  • https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170 – user17732522 Mar 02 '22 at 14:27

0 Answers0