Skip to content

Instantly share code, notes, and snippets.

@zakky-dev
Created August 12, 2013 08:10
Show Gist options
  • Save zakky-dev/6209011 to your computer and use it in GitHub Desktop.
Save zakky-dev/6209011 to your computer and use it in GitHub Desktop.
privateメンバにアクセスできてる?
import std.stdio;
struct Structure {
public:
int public_integer = 10;
private:
int private_integer = 20;
}
void main() {
Structure s;
with(s) {
writeln(public_integer);
writeln(private_integer);
public_integer = 30;
private_integer = 40;
writeln(public_integer);
writeln(private_integer);
}
s.public_integer = 50;
s.private_integer = 60;
writeln(s.public_integer);
writeln(s.private_integer);
}
@zakky-dev
Copy link
Author

解決。
D言語の仕様で、同じモジュール内ならprivateでも見えるとのこと。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment