diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-04-03 14:14:49 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-04-03 14:14:49 +0200 |
commit | 6e2556ab445169cadb21d9ba16eb77d7350a79f7 (patch) | |
tree | cd7360bd946870f204af69b8ed057cb3c59663be /documentation/classes-and-objects.html | |
parent | 8ce7055ebfbd28f283e08eb822980a7f4641c0cd (diff) |
update documentation about inheritance
Diffstat (limited to 'documentation/classes-and-objects.html')
-rw-r--r-- | documentation/classes-and-objects.html | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/documentation/classes-and-objects.html b/documentation/classes-and-objects.html index e0087b6..fe1c9b5 100644 --- a/documentation/classes-and-objects.html +++ b/documentation/classes-and-objects.html @@ -567,60 +567,6 @@ extern "C" { To register abstract methods, you can simply use an alternative form of the Counter::method() method that does not take a pointer to a C++ method. </p> -<h2 id="interfaces">Interfaces</h2> -<p> - In C++ interfaces do not exist. C++ supports multiple inheritance, which is - more powerful than interfaces or traits. Interfaces and traits are basically - PHP workarounds to make up for not having multiple inheritance. So when - you're writing C++ code, you don't need interfaces or traits. -</p> -<p> - In case you want your extension to <i>define</i> an interface, so that the - interface can be implemented from PHP user space scripts, you can do that - almost in a similar way to how you would define an abstract class. The only - difference is that you will not use a Php::Class instance to define the - methods, but a Php::Interface instance. The interface does not have to be - linked to a real C++ class (it is an interface after all), so the - Php::Interface does not have to be passed the name of a C++ class. -</p> -<p> -<pre class="language-c++"><code> -/** - * Switch to C context to ensure that the get_module() function - * is callable by C programs (which the Zend engine is) - */ -extern "C" { - /** - * Startup function that is called by the Zend engine - * to retrieve all information about the extension - * @return void* - */ - PHPCPP_EXPORT void *get_module() { - // create static instance of the extension object - static Php::Extension myExtension("my_extension", "1.0"); - - // description of the interface so that PHP knows which methods - // are defined by it - Php::Interface interface("MyInterface"); - - // define an interface method - interface.method("myMethod", { - Php::ByVal("value", Php::Type::String, true) - }); - - // register other methods - ... - - // add the interface to the extension - // (or move it into the extension, which is faster) - myExtension.add(std::move(interface)); - - // return the extension - return myExtension; - } -} -</code></pre> -</p> <p> There is much more to say about classes and objects, in the next section we'll explain <a href="constructors-and-destructors">constructors and |