මචන්ලා මේක මන් කරලා තියෙනවා හරිද ?වැරදි තියෙනවනම් කියන්න.මේක මිට වැඩ හොදට කරන්න පුලුවන්නම් එකත් පොඩ්ඩක් කියන්න.
The part of a banking application has two classes Person and class Account_Holder. The attributes and functions of each class are given below. Assume the function ShowDetails() is a pure virtual function.
Write an object-oriented application using C++ to perform the following.
i. Set the NIC number, Account number of one account holder.
ii. Show the NIC number and Account number of the account holder overriding function showDetails() in the class Person.
Class Person:
NIC number
SetNIC() //set NIC number of the person
ShowDetails() //display NIC number of the person.
Class Account_Holder:
Account number
SetAccountNumber() // set Account number of the account holder.
The part of a banking application has two classes Person and class Account_Holder. The attributes and functions of each class are given below. Assume the function ShowDetails() is a pure virtual function.
Write an object-oriented application using C++ to perform the following.
i. Set the NIC number, Account number of one account holder.
ii. Show the NIC number and Account number of the account holder overriding function showDetails() in the class Person.
Class Person:
NIC number
SetNIC() //set NIC number of the person
ShowDetails() //display NIC number of the person.
Class Account_Holder:
Account number
SetAccountNumber() // set Account number of the account holder.
Code:
#include<iostream>
using namespace std;
class person
{
public:
string nicnumber;
void setNic(string NIC)
{
nicnumber = NIC;
}
virtual void showDetails()
{
cout << "NIC NUMBER IS " << nicnumber << endl;
}
};
class Acount_holder : public person
{
public:
int accountnumber;
void setAccountnumber(int n)
{
accountnumber = n ;
}
void showDetails()
{
cout << "Account number is " << accountnumber << endl;
}
};
int main()
{
person a;
a.setNic("930501352v");
a.showDetails();
Acount_holder b;
b.setAccountnumber(123);
b.showDetails();
return 0;
};
Last edited: