Skip to main content

All Questions

Tagged with
0 votes
1 answer
729 views

why can't I access a protected method from a private method if the protected ones are inherited by the subclasses?

I do not understand this particular case or what Alexander says. class instance is not the same as class? As already Alexander Larikov said that you can't access protected methods from class instance ...
user avatar
1 vote
2 answers
2k views

Private property in parent class can be accessed and re-assigned through the instance of child class in PHP but protected one can't

I am very confused why $produk1->harga = 500; can still make a change (or re-assign the value 500) to private $harga property despite private $harga in class Produk has PRIVATE visibility ? $...
didaen's user avatar
  • 48
7 votes
5 answers
237 views

Is it possible to use a class declared in Implementation section from Interface section

If I understand correctly, the interface section is visible to other units, and the implementation section is visible only in the current .pas file. I have two classes, class TA should be visible to ...
Bruice's user avatar
  • 633
1 vote
1 answer
146 views

Inheritance in C: how to hide "super class" attributes to the class extending it

As a learning experience I'm trying to achieve simple class inheritence in C, among other OOP features. So far I've been able to properly hide "private" functions and attributes of a class from the ...
Gian's user avatar
  • 357
0 votes
2 answers
285 views

Method defined in superclass but implemented in subclass: accessing subclass attributes?

Here's my class structure: class Parent { public: void foo(); // foo() defined in superclass }; class Child : public Parent { private: int bar; public: Child(int);...
gator's user avatar
  • 3,513
3 votes
1 answer
1k views

Some C symbols in a C shared library are not exported even with explicit visibility

Preface I'm developing an object oriented library in C that targets both Linux and Windows. At the moment I'm developing on a Linux VM (Guest), because I'm using clang sanitizers. I'm building with ...
user avatar
1 vote
2 answers
140 views

Can I use packages without making all of the methods/ attributes public?

I have a project with about 10 classes. I moved some classes to a package for clarity. Is there a safe way to connect between classes without data leaks? -using public is dangerous because anyone can ...
benjamin's user avatar
  • 353
4 votes
1 answer
804 views

Why can child override and access its parent private method?

I'm used to put method as protected in my PHP classes. But playing with private I'm starting to have doubts. I know that it might be a duplicate but I can't find clarity from the SO-answers I've ...
Kamafeather's user avatar
  • 9,461
0 votes
1 answer
533 views

Parent's protected properties inaccessible to child object

I have a parent class I'll be calling 'ParentClass' and a child class (that extends from it) which I'll be calling 'ChildClass'. ParentClass has protected properties $prop1 and $prop2 which I want ...
Douglas Silva's user avatar
1 vote
2 answers
61 views

Java: protected, visibitily [duplicate]

I'm a bit confused about the whole protected thing in java. If something is protected only the classes within the same package can access it, right? Should we use protected private attributes in a ...
user8716414's user avatar
0 votes
4 answers
736 views

How to make a member of a class to be accessible only in subclasses in any packages?

How to make a member of a class to be accessible only in subclasses in any packages? Protected is not a solution since it will open the member to other non subclasses classes.
Yaroslav's user avatar
  • 1,325
2 votes
3 answers
2k views

PHP: Changing default visibility of undeclared class properties to protected/private

In PHP, undeclared class properties/variables will default to "public" visibility. Is there a way (for certain classes, but not all) to change the default visibility to "protected" (or private)? I ...
LaVache's user avatar
  • 2,579
0 votes
1 answer
130 views

Is it possible to truly limit access of this private property?

I'm using three tricks in my attempt: Reflections can't be used with dynamic class properties __get() or __set() must be called when accessing dynamic class properties debug_backtrace() can be ...
SOFe's user avatar
  • 8,081
-1 votes
1 answer
67 views

Strange PHP Reaction

I'm getting some wierd reactions when running this script. <?php error_reporting(E_ALL); class A { protected $varOne = array( "subVar1" => "", "subVar2"...
Alex's user avatar
  • 3
6 votes
2 answers
2k views

What's the visibility of a class by default in PHP?

I could find the default visibility of a property and a method in the PHP manual. But i couldn't find any info regarding the class itself. My guess is that it's public. But if someone could link to ...
Jo Smo's user avatar
  • 7,053

15 30 50 per page