Skip to content

Commit

Permalink
fixed example
Browse files Browse the repository at this point in the history
  • Loading branch information
EmielBruijntjes committed Mar 12, 2014
1 parent 9111e1d commit 5ecddd3
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions documentation/classes-and-objects.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ <h2>Static methods</h2>
/**
* A very simple class that will be exported to PHP
*/
class PublicClass : Php::Base
class PublicClass : public Php::Base
{
public:
/**
Expand Down Expand Up @@ -380,7 +380,7 @@ <h2>Static methods</h2>
myClass.method("static3", &amp;PrivateClass::staticMethod);

// add the class to the extension
myExtension.add(std::move(counter));
myExtension.add(std::move(myClass));

// In fact, because a static method has the same signature
// as a regular function, you can also register static
Expand All @@ -397,7 +397,25 @@ <h2>Static methods</h2>
It is questionable how useful this all is. It is probably advisable to keep
your code clean, simple and maintainable, and only register static PHP methods
that are also in C++ static methods of the same class. But C++ does not forbid
you to do it completely different.
you to do it completely different. Let's round up with an example how to
call the static methods
</p>
<p>
<pre class="language-c++"><code>
&lt;?php
// this will call PublicClass::staticMethod()
MyClass::static1();

// this will call PrivateClass::staticMethod()
MyClass::static2();

// this will call regularFunction
MyClass::static3();

// this will call PrivateClass::staticMethod
myFunction();
?&gt;
</code></pre>
</p>
<h2>Access modifiers</h2>
<p>
Expand Down

0 comments on commit 5ecddd3

Please sign in to comment.