Document number: Date: 2021-08-26 Project: Programming Language C++ Reply-to: Valery Osheter I. Introduction This document proposes to allow the declaration of a non-virtual public method outside of the class definition. The method is declared without a body. II. Motivation The main goal is to make it easier to hide implementation details in most cases. There should be an easy way to implement this fundamental concept of OOP in C++. It works in C++ when we have a plain function, but the same feature is not available for class methods. Unfortunately, the public interface part of the class must be declared together with the private part, although it is not always necessary. As a result, people are forced to use an inefficient PIMPL. Another way is to define an interface class that is used solely to hide the implementation details. Both methods are difficult for beginners, while a simple and clear solution is almost ready for use in everyday programming. III. Solution This is a forward declaration of methods outside of the class definition. Note that C++ allows to declare a plain function without a body. The idea is to reuse the same approach for non-virtual public methods. In most cases, no additional information about the class structure is required to generate a method call. Therefore, the full definition of the class here is an unnecessary restriction. IV. Error Handling If the declaration does not match, the result will be the same as in the case of a plain function. That is the linker error. V. Example struct foo; void foo::bar(); // this is the method declaration without a body. void test(foo& f) { f.bar(); } VI. Impact on the Standard The impact of this proposal on the standard is minimal. It requires neither new reserved words nor a change in the low-level syntax. Existing C++ code does not require recompilation if this proposal is accepted. VII. Impact on the Programming Style and Flow A C++ student learns to separate the public class interface and the implementation. A class developer prepares the class interface before diving to the implementation code. A tester writes and compiles tests before the class implementation is ready. If the implementation of the class changes, the code using this class should not be recompiled. In most cases PIMPL turns out to be an old bad technics.