}// method to display a messagegreet() {console.log(`Hello, my name is${this.name}and I am${this.age}years old.`); } }// create two objects of the Person classletperson1 =newPerson("Jack",30);letperson2 =newPerson("Tina",33);// call greet() method on two instancesperson1....
All subclasses of a sealed class must be declared in the same file where sealed class is declared. A sealed class isabstractby itself, and you cannot instantiate objects from it. You cannot create non-private constructors of a sealed class; their constructors areprivateby default. ...
Here,ClassBis a friend class ofClassA. So,ClassBhas access to the members ofclassA. InClassB, we have created a functionadd()that returns the sum ofnumAandnumB. SinceClassBis a friend class, we can create objects ofClassAinside ofClassB. Also Read: Previous Tutorial: C++ Encapsulation...