Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class DZS
- {
- private:
- int *student;
- public:
- int getAmount();
- DZS(int amount);
- DZS(const DZS &lol);
- ~DZS();
- };
- DZS::DZS(int amount)
- {
- cout << "Constructor Called"<<endl;
- student = new int;
- *student = amount;
- }
- DZS::DZS(const DZS &lol)
- {
- cout << " COPY Constructor Called"<<endl;
- student = new int;
- *student = *lol.student;
- }
- DZS::~DZS()
- {
- cout << "Destreactor Called."<<endl;
- delete student;
- }
- int DZS::getAmount()
- {
- return *student;
- }
- void display(DZS lol)
- {
- cout << "Total Student in DZS is: " << lol.getAmount() <<endl;
- }
- int main()
- {
- DZS dzs(2000);
- display(dzs);
- }
Advertisement
Add Comment
Please, Sign In to add comment