Adjust PHP sync example
Make it work with how globals are actually wrapped. It looks like this example has never been right, but nobody noticed before PHP 8 started warning about the use of unset variables. This reveals that handling of std::string properties needs fixing.
This commit is contained in:
parent
3b63ef27fe
commit
a49cc60772
3 changed files with 48 additions and 16 deletions
|
|
@ -1,13 +1,19 @@
|
|||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
int x = 42;
|
||||
char *s = (char *)"Test";
|
||||
std::string s = "Test";
|
||||
|
||||
void Sync::printer(void) {
|
||||
|
||||
printf("The value of global s is %s\n", s);
|
||||
printf("The value of global x is %d\n", x);
|
||||
printf("The value of class s is %s\n", s);
|
||||
printf("The value of class x is %d\n", x);
|
||||
void Sync::printer() {
|
||||
std::cout << "The value of global s is " << ::s << '\n';
|
||||
std::cout << "The value of global x is " << ::x << '\n';
|
||||
std::cout << "The value of class s is " << this->s << '\n';
|
||||
std::cout << "The value of class x is " << this->x << '\n';
|
||||
}
|
||||
|
||||
void Sync::all_change() {
|
||||
::s = "global change";
|
||||
++::x;
|
||||
this->s = "local change";
|
||||
++this->x;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue