Linked Questions
17 questions linked to/from What are public, private and protected in object oriented programming?
0 votes
5 answers
2k views
Protected functions in PHP [duplicate]
This may seem pretty simple and I am sure it is, I am just not getting it. I understand that protected properties in a class in PHP can only be accessed within the class itself and inherited classes. ...
-2 votes
3 answers
275 views
Why is 'private' used in object oriented program? [duplicate]
There are 'public', 'private', and 'protected' in oop like c++ language. And I tried two kinds of simple programs. Below is first case in c++. class A { public: string name; } int main(void) ...
0 votes
0 answers
171 views
C++ compile error, after fixing The include file error [duplicate]
Dear all I have this code running on visual studio . I am getting error as below I have taken example from books. I have installed visual studio recently. I have tested basic code working well. I am ...
0 votes
0 answers
30 views
What is a public interface in C++ [duplicate]
On isocpp - faq for references it states: References are usually preferred over pointers whenever you don’t need “reseating”. This usually means that references are most useful in a class’s public ...
9 votes
1 answer
319 views
Inheriting private attributes in Perl 6
I can't find anything in the docs, but it seems that there is no access in a subclass to its superclass's private variables. Am I right? class A { has $!a; } class B is A { has $.b; method ...
-6 votes
4 answers
11k views
Difference between "public" and "void" [duplicate]
I am learning java programming from http://courses.caveofprogramming.com/courses/java-for-complete-beginners/lectures/38443 This guy, till now have been using the void keyword before declaring any ...
2 votes
6 answers
4k views
Inheritance and access modifier
I have the following simple C# code, but I do not understand the output. using System; namespace ConsoleApplication4 { class myParent { public int id = 3; private string name ...
1 vote
2 answers
719 views
php security protected vs. private
I am trying to build an application in php and I have an encrypt/decrypt method that I am deploying, to enhance the security I declared these two methods as protected and I plan to have any class that ...
1 vote
2 answers
3k views
PHP PDO - INSERT INTO with bindParam does not work
I stucked at this little piece of code: $fruit_object = new fruit(1234, 'apple', 'red apple'); try { $dbh = new PDO('mysql:host=localhost;charset=utf8;dbname=database', 'user', 'password'); ...
0 votes
5 answers
2k views
using base class methods that use private field
I have a class, it has several public methods that use one private field that they all changed and use this field in their computations. I need subclass from this class with few new methods, new ...
3 votes
2 answers
2k views
Does access modifiers have any role to play in Encapsulation [closed]
Here is a class Encapsulate which has public property and a public method. class Encapsulate { public int a; public int b; public static void main(String...s) { Encapsulate e = new ...
2 votes
1 answer
1k views
Is it possible to extend a class without extending the methods of this class?
The title says it all. I have a class with a lot of variables and a lot of methods in it. class bootstrap_class { public //-----Counters--------- $iColumn_count, $iLink_count, $iDia_count, $...
0 votes
3 answers
472 views
C++ - Constructor Inheritance with private parameters
Hello I have trouble with working an inheritance constructor. I can't access the parent's fields. Here is my MyClass.h: #include "Parent.h" class MyClass : public Parent { public: MyClass(...
0 votes
2 answers
327 views
Access parents parent class
I have the class structure below. I was wondering how I can access $varA from class C. And if I change a value within class A is it also visible in class C? Or when I call class C, are all the values ...
-6 votes
4 answers
212 views
Different behavior of C++ with default value for public vs private scope
I have two questions 1) Why can we give default value if the member is public but when it is private we are not allowed? Take below example: #include <iostream> using namespace std; class ...