Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8585015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:57:23+00:00 2026-06-11T21:57:23+00:00

class Master{ protected static $DB; function __construct(){ static::$DB = new DB(); $view = new

  • 0
class Master{
  protected static $DB;
  function __construct(){
    static::$DB = new DB();
    $view = new View();
  }
}

class DB extends Master{
  private function ReturnSomeData(){
    return $data;
  }
}

class View extends Master{
  public function ViewData(){
    $DBdata = static::$DB->ReturnSomeData();
  }
}

Fatal error: Call to private method DB::ReturnSomeData() from context ‘View’

How can I access the ReturnSomeData() method from the View class? Is there something like a ‘gateway’?

class Master {
... }

class DB extends Master{
...
  public function PassItToMe(){
    return $this;
  }
}

class View extends Master{
  public function ViewData(){
    $DBdata = static::$DB->PassItToMe()->ReturnSomeData();
   }
}

This is my picture right now, but I’m really lost.
The idea is that I want to access private methods from one child class to another.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:57:24+00:00Added an answer on June 11, 2026 at 9:57 pm

    You have to choose:

    • you want to keep ReturnSomeData() private? Fine, you won’t be able to access it from outside class [not even subclasses];
    • you want to access ReturnSomeData()? Make it public.

    The idea is to make private [or protected] fields, and public accessors in case, that is one of the main points of encapsulation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the following master.cs code: public partial class Default : System.Web.UI.MasterPage { protected void
public class master extends Activity { ProgressDialog progressDialog; EditText tahmini_kelime; EditText girilen_sayi ; EditText
in my form <?php class ChangeMyPasswordForm extends sfForm { protected static $labels = array(
My master page: public partial class MasterPages_Main : System.Web.UI.MasterPage { public bool IsLoggedIn; protected
public abstract class Master { public void printForAllMethodsInSubClass() { System.out.println (Printing before subclass method
Class 1 private void checkDuplicateCustomer(BulkCustomerVO bulkCustomerVO) { PagedDuplicateCustomerVO duplicateCustomerVO = new PagedDuplicateCustomerVO(); duplicateCustomerVO.setCustomer(bulkCustomerVO.getCustomerVO()); duplicateCustomerVO
Here is my master page code behind: namespace mysite.MasterPages { public partial class Main
I have the following class... public class MyCustomLogger { public static int DEFAULT_INFO =
I have a master page with the following code: public partial class MasterPage :
In my Site.Master.vb file, I have a custom User object: Public Class Site Inherits

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.