{
    "mode": "perldoc",
    "parameter": "Class::Virtual",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AVirtual/json",
    "generated": "2026-06-12T12:14:50Z",
    "synopsis": "package My::Virtual::Idaho;\nuse base qw(Class::Virtual);\nPACKAGE->virtualmethods(qw(new foo bar this that));\npackage My::Private::Idaho;\nuse base qw(My::Virtual::Idaho);\n# Check to make sure My::Private::Idaho implemented everything\nmy @missing = PACKAGE->missingmethods;\ndie PACKAGE . ' forgot to implement ' . join ', ', @missing\nif @missing;\n# If My::Private::Idaho forgot to implement new(), the program will\n# halt and yell about that.\nmy $idaho = My::Private::Idaho->new;\n# See what methods we're obligated to implement.\nmy @mustimplement = PACKAGE->virtualmethods;",
    "sections": {
        "NAME": {
            "content": "Class::Virtual - Base class for virtual base classes.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package My::Virtual::Idaho;\nuse base qw(Class::Virtual);\n\nPACKAGE->virtualmethods(qw(new foo bar this that));\n\n\npackage My::Private::Idaho;\nuse base qw(My::Virtual::Idaho);\n\n# Check to make sure My::Private::Idaho implemented everything\nmy @missing = PACKAGE->missingmethods;\ndie PACKAGE . ' forgot to implement ' . join ', ', @missing\nif @missing;\n\n# If My::Private::Idaho forgot to implement new(), the program will\n# halt and yell about that.\nmy $idaho = My::Private::Idaho->new;\n\n# See what methods we're obligated to implement.\nmy @mustimplement = PACKAGE->virtualmethods;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "THIS MODULE IS DISCOURAGED! Avoid using it for new code. There's nothing wrong with it, but\nthere are better ways to accomplish the same thing. Look into the Moose ecosystem.\n\nThis is a base class for implementing virtual base classes (what some people call an abstract\nclass). Kinda kooky. It allows you to explicitly declare what methods are virtual and that must\nbe implemented by subclasses. This might seem silly, since your program will halt and catch fire\nwhen an unimplemented virtual method is hit anyway, but there's some benefits.\n\nThe error message is more informative. Instead of the usual \"Can't locate object method\" error,\nyou'll get one explaining that a virtual method was left unimplemented.\n\nSubclass authors can explicitly check to make sure they've implemented all the necessary virtual\nmethods. When used as part of a regression test, it will shield against the virtual method\nrequirements changing out from under the subclass.\n\nFinally, subclass authors can get an explicit list of everything they're expected to implement.\n\nDoesn't hurt and it doesn't slow you down.\n",
            "subsections": [
                {
                    "name": "Methods",
                    "content": "virtualmethods\nVirtual::Class->virtualmethods(@virtualmethods);\nmy @mustimplement = Sub::Class->virtualmethods;\n\nThis is an accessor to the list of virtualmethods. Virtual base classes will declare their\nlist of virtual methods. Subclasses will look at them. Once the virtual methods are set they\ncannot be undone.\n\nmissingmethods\nmy @missingmethods = Sub::Class->missingmethods;\n\nReturns a list of methods Sub::Class has not yet implemented.\n\nCAVEATS and BUGS\nAutoloaded methods are currently not recognized. I have no idea how to solve this.\n"
                }
            ]
        },
        "AUTHOR": {
            "content": "Michael G Schwern <schwern@pobox.com>\n",
            "subsections": []
        },
        "LEGAL": {
            "content": "Copyright 2000-2015 Michael G Schwern\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n\nSee <http://dev.perl.org/licenses/>\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Class::Virtually::Abstract\n",
            "subsections": []
        }
    },
    "summary": "Class::Virtual - Base class for virtual base classes.",
    "flags": [],
    "examples": [],
    "see_also": []
}