public

Friend declaration in C++ - difference between public and private

对着背影说爱祢 提交于 2019-11-28 03:02:56
Is there a difference between declaring a friend function/class as private or public? I can't seem to find anything about this online. I mean the difference between: class A { public: friend class B; }; and class A { private: //or nothing as the default is private friend class B; }; Is there a difference? No, there's no difference - you just tell that class B is a friend of class A and now can access its private and protected members, that's all. Since the syntax friend class B doesn't declare a member of the class A , so it doesn't matter where you write it, class B is a friend of class A .

Why main method is marked as public?

China☆狼群 提交于 2019-11-27 23:18:05
I have a question that why main method is marked as public ? According to an answer on stackoverflow, It is declared as static "The method is static because otherwise there would be ambiguity: which constructor should be called?" But, can anyone can explain why it is declared public always? The initialization software that starts your program must be able to see main so that it can call it. Because the JLS, Section 12.1.4 , says so: The method main must be declared public, static, and void. It must specify a formal parameter (§8.4.1) whose declared type is array of String. If it's not public ,

Inline function cannot access non-public-API: @PublishedApi vs @Suppress vs @JvmSynthetic

ε祈祈猫儿з 提交于 2019-11-27 22:50:39
In Kotlin, when I have a non-public member and an inline fun that calls it, there's a compilation error saying: Error:(22, 25) Kotlin: Public-API inline function cannot access non-public-API private fun f(): Unit defined in com.example I found several ways to call my function inside a public inline fun , but which is the best way to do it? Suppose I have a private fun f() { } . Then the options I found are: fun f() { } Just make it public. This is the baseline solution, but if the others turn out to have major disadvantages, this can end up the best one. @PublishedApi internal fun f() { }

protected vs public constructor for abstract class? Is there a difference?

廉价感情. 提交于 2019-11-27 20:39:12
问题 This question is out of curiosity. Is there a difference between: public abstract class MyClass { public MyClass() { } } and public abstract class MyClass { protected MyClass() { } } Thanks. 回答1: They are the same for all practical purposes. But since you asked for differences, one difference I can think of is if you are searching for the class's constructor using reflection, then the BindingFlags that match will be different. BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;

Call-time pass-by-reference has been removed [duplicate]

让人想犯罪 __ 提交于 2019-11-27 20:21:31
Possible Duplicate: Call-time pass-by-reference has been deprecated While it may be documented somewhere on the internet, I cannot find a solution to my problem. Since the PHP 5.4 update, pass-by-references have been removed. Now I have a problem with this section of code, and I hope somebody can see what I'm trying to do with it so that they can possibly help me with a solution to overcome my pass-by-reference problem. Below is the code in question: public function trigger_hooks( $command, &$client, $input ) { if( isset( $this->hooks[$command] ) ) { foreach( $this->hooks[$command] as $func )

C# winform: Accessing public properties from other forms & difference between static and public properties

不羁的心 提交于 2019-11-27 19:08:11
问题 I am trying to understand whats the difference between a static and public properties. But when I tried to access my public property 'Test' in other form it says 'null'. Heres Form1: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private string _test; public string Test { get { return _test; } set { _test = value; } } private void Form1_Load(object sender, EventArgs e) { _test = "This is a test"; } private void button1_Click(object sender, EventArgs e) { Form2

Why does Typescript use the keyword “export” to make classes and interfaces public?

◇◆丶佛笑我妖孽 提交于 2019-11-27 17:45:49
While dabbling with Typescript I realised my classes within modules (used as namespaces) were not available to other classes unless I wrote the export keyword before them, such as: module some.namespace.here { export class SomeClass{..} } So now I can use the above code like this: var someVar = new some.namespace.here.SomeClass(); However I was just wondering why this keyword is used opposed to just using the public keyword which is used at method level to signify that a method or property should be externally accessible. So why not just use this same mechanism to make classes and interfaces

Why use a public method in an internal class?

痞子三分冷 提交于 2019-11-27 16:45:23
There is a lot of code in one of our projects that looks like this: internal static class Extensions { public static string AddFoo(this string s) { if (!string.IsNullOrEmpty(s)) return s + "Foo"; return "Foo"; } } Is there any explicit reason to do this other than "it is easier to make the type public later?" I suspect it only matters in very strange edge cases (reflection in Silverlight) or not at all. UPDATE: This question was the subject of my blog in September 2014 . Thanks for the great question! There is considerable debate on this question even within the compiler team itself. First off

Github (SSH) via public WIFI, port 22 blocked

安稳与你 提交于 2019-11-27 16:39:40
I'm currently on a public WIFI spot and I'm unable to use SSH (they probably blocked that port). However, I need that connection to do a git push . ➜ ssh -T git@github.com ssh: connect to host github.com port 22: Connection refused Is it possible to bypass this restriction by setting up a SSH tunnel via port 80 and tell github push to use that connection? How to do that? I'm on OSX (lion). This must be a common problem? prtitrz Try this: $ vim ~/.ssh/config Add Host github.com Hostname ssh.github.com Port 443 Source: https://help.github.com/articles/using-ssh-over-the-https-port the_karel The

Public static variable value

[亡魂溺海] 提交于 2019-11-27 15:41:08
I'm trying to declare a public static variable that is a array of arrays: class Foo{ public static $contexts = array( 'a' => array( 'aa' => something('aa'), 'bb' => something('bb'), ), 'b' => array( 'aa' => something('aa'), 'bb' => something('bb'), ), ); // methods here } function something($s){ return ... } But I get a error: Parse error: parse error, expecting `')'' in ... You can't use expressions when declaring class properties. I.e. you can't call something() here, you can only use static values. You'll have to set those values differently in code at some point. Like any other PHP static