function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SaifSaif 

How to call data members from one class to another class?

Hi,
I have two classes Class1(parent) & Class2 (child)
Public parnent{
public string a;
public string b;
public string c;
}//end of  class 1
Public child{
public string x;
public string y;
public string z;
}//end of class 2
here I want to access a,b,c into child class what is the syntax to call from child to parent class
I tried  below syntax it is throwing an error 
Public class child extends parent
{


Thanks in advance
Raj VakatiRaj Vakati
the extending class can override the existing virtual methods by using the override keyword in the method definition. Overriding a virtual method allows you to provide a different implementation for an existing method. This means that the behavior of a particular method is different based on the object you’re calling it on. This is referred to as polymorphism.

refer this link 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_example.htm
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_extending.htm​​​​​​​
 
public virtual class Parent{
    public string x;
    public string y;
    public string z;
}//end of class 2
 
public class child extends Parent {
    public child(){
        System.debug('x'+x);
    }
   
}//end of class 2