Ok, so this may be a bit of a silly question, and there's certainly the obvious answer, but I was curious if I've missed any subtleties here.
Is there any difference in terms of visibility/usability between a public member declared in an internal class and an internal member declared in an internal class?
i.e. between
internal class F...
I'm confused about the errors generated by the following code.
In Derived::doStuff, I can access Base::output directly by calling it.
Why can't I create a pointer to output() in the same context that I can call output()?
(I thought protected / private governed whether you could use a name in a specific context, but apparently that is i...
Are the following equivalent?
private static boolean readAllFiles = false,readAllDirs = false;
private static boolean readAllFiles = false;
private static boolean readAllDirs = false;
And if so, do they still have the same modifiers with different values?
private static boolean readAllFiles = false,readAllDirs = true;
...
In C++, you can do the following:
class base_class
{
public:
virtual void do_something() = 0;
};
class derived_class : public base_class
{
private:
virtual void do_something()
{
std::cout << "do_something() called";
}
};
The derived_class overrides the method do_something() and makes it private. The effect is...
Suppose I have a class in my package org.jake and it has a method with default access (no modifier). Then the method is visible inside the package only.
However, when someone receives the jar of my framework, what is to stop them from writing a new class, declaring its package as org.jake, and using my supposedly invisible method?
In ...
Is there a way in PHP5 to only allow a certain class or set of classes to call a particular function? For example, let's say I have three classes ("Foo", "Bar", and "Baz"), all with similarly-named methods, and I want Bar to be able to call Foo::foo() but deny Baz the ability to make that call:
class Foo {
static function foo() { pr...
I have an abstract class, relation in package database.relation and a subclass of it, Join, in package database.operations. relation has a protected member named mStructure.
In Join:
public Join(final Relation relLeft, final Relation relRight) {
super();
mRelLeft = relLeft;
mRelRight = relRight;
mStruct...
Why is it that some components/controls will not be inherited visually in a child form if they are declared with the access modifier Friend vs when they are declared with Protected.
For example, I've got a DataSet object in my Parent Form that was initially "Friend" (I drag and dropped it to the form, so it was shown as a control in th...
I come from more of a C# background yet am learning Ruby in my spare time.
Given classes, it is possible to make their methods private, public (default) or protected. While I understand their usage, is it typical for Ruby code to make use of such modifiers, despite being a dynamic language, in which the user can easily override access?
...
If I say
class A{
}
then it implicitly inherits Object class.So I am having the class as below:
class A{
protected Object clone(){
} /// Here i am not overridning
//All the other methods (toString/wait/notify/notifyAll/getClass)
}
Now Why cant I access the clone() method in Class B which is in the same packag...
I just came across code that had protected static class functions, as in:
class C {
...
protected:
static int fun() { ... }
};
I got curious if static class functions could have access modifiers and what would it mean? Since they are class globals and not pre-instance.
Thanks, Boda Cydo.
...
After a little research I've determined that the only access modifiers which you can apply to classes are:
public - available in any assembly
internal - available only in the current assembly
but the error message below seems to imply that if a class is not defined in a namespace that it could be defined as private, protected, or pro...
I am trying to figure out a system that can easily modify objects on the fly.
here is an example, Lets say I have an Entity2D that inherits from Entity. Entity2D has a Position property.
Now I have a class called ModifyPosition that inherits from Modifier.
Here is some code
public class Entity
{
/// <summary>
/// Applies the modifier...
I just realized that the C# property construct can also be used with a private access modifier:
private string Password { get; set; }
Although this is technically interesting, I can't imagine when I would use it since a private field involves even less ceremony:
private string _password;
and I can't imagine when I would ever need t...
Hey,
Take a look at this code:
#include <iostream>
using namespace std;
class A
{
private:
int privatefield;
protected:
int protectedfield;
public:
int publicfield;
};
class B: private A
{
private:
A a;
public:
void test()
{
cout << this->publicfield << this->protectedfield << endl;
}
void tes...
Hi all,
I am not able to understand why this code doesnt compile :
class A {
public static void main(String[] args) {
System.out.println("hi");
}
}
private class B {
int a;
}
I am saving the contents in a file named A.java - and I get an error :
modifier private not allowed here // where I have def...
I think sealed should be included in the list of access modifiers in C# language. Can somebody tell the reason why it has been excluded?
...
I have three classes. all are part of the same namespace. here are the basics of the three classes.
//FBlock.cs
namespace StubGenerator.PropGenerator
{
class FBlock : IDesignRegionInserts, IFormRegionInserts, IAPIRegionInserts, IConfigurationInserts, ISoapProxyClientInserts, ISoapProxyServiceInserts
{
private List<Prope...
if I will create new object like this:
Object objectA = new Object();
Which access modifier it will have by default?
...
Ok so I was just thinking to myself why do programmers stress so much when it comes down to Access Modifiers within OOP.
Lets take this code for example / PHP!
class StackOverflow
{
private var $web_address;
public function setWebAddress(){/*...*/}
}
Because web_address is private it cannot be changed by $object->web_address...