55 lines
1.0 KiB
C++
55 lines
1.0 KiB
C++
#include <iomanip>
|
|
#include <iostream>
|
|
|
|
class Date {
|
|
private:
|
|
int d, m, y;
|
|
|
|
public:
|
|
Date(int dd = 0, int mm = 0, int yy = 0);
|
|
Date(Date &D);
|
|
~Date();
|
|
void display();
|
|
};
|
|
|
|
Date::Date(int dd, int mm, int yy) : d(dd), m(mm), y(yy) {
|
|
std::cout << "Constructor called! Address = 0x" << std::hex << std::setw(8)
|
|
<< std::setfill('0') << this << std::endl;
|
|
}
|
|
|
|
Date::Date(Date &D) {
|
|
d = D.d;
|
|
m = D.m;
|
|
y = D.y;
|
|
std::cout << "Copy constructor called! Address = 0x" << std::hex
|
|
<< std::setw(8) << std::setfill('0') << this << std::endl;
|
|
}
|
|
|
|
Date::~Date() {
|
|
std::cout << "Destructor called! Address = 0x" << std::hex << std::setw(8)
|
|
<< std::setfill('0') << this << std::endl;
|
|
}
|
|
|
|
void Date::display() {
|
|
std::cout << "Displaying" << std::endl;
|
|
}
|
|
|
|
// Date func(Date A) {
|
|
// Date B(A);
|
|
// return B;
|
|
// }
|
|
|
|
// Date & func(Date A) {
|
|
// Date B(A);
|
|
// return B;
|
|
// }
|
|
|
|
Date func(Date A) {
|
|
return A;
|
|
}
|
|
|
|
int main() {
|
|
Date today;
|
|
today = func(today);
|
|
return 0;
|
|
} |