I am trying to call my Person class constructor from my Resident class
Person:
public class Person
{
private String name;
private String surname;
private String address1;
private String address2;
private String telephone;
private String faxNumber;
Person(String aName, String aSurname, String aAddress1, String aAddress2, String aTelephone, String aFaxNumber)
{
name = aName;
surname = aSurname;
address1 = aAddress1;
address2 = aAddress2;
telephone = aTelephone;
faxNumber = aFaxNumber;
}
Resident:
public class Resident : Person
{
private String IDNumberPrim;
private String IDNumberSec1;
private String IDNumberSec2;
private String IDNumberSec3;
private String IDNumberSec4;
private String tempID;
private String passportNumber;
Resident(String aIDNumberPrim, String aIDNumberSec1, String aIDNumberSec2, String aIDNumberSec3, String aIDNumberSec4, String aTempId, String aPassportNumber)
I have tried the base command, but it never works.
Please help!!!
————UPDATE—————-
Problem solved.
Thanks for all the help and suggestions
You should add the
publickeyword for the constructor, if you want it’s access to be public:You could also use
internalif they are on the same project, orprotected, since one is a base of the other, etc, but it all depends on what you really want to access modifier for the ctor to be.The default access modifier is
private, which does not allow anything from outside that class access that.