Skip to content

add a copy constructor and operator= #1

@predicteur

Description

@predicteur

Hy,

I try to use your DTime class (it's very usefull), but it's not possible to do that :

DTime dateActuel = dateRef;

So, i propose to add a copy constructor and an overload for operator= like this :

in DTime.h :

DTime(const DTime & z);
DTime& operator=(const DTime & z);

in DTime.cpp :

DTime::DTime(const DTime & z) {
	_year = z.year;
	_month = z.month;
	_day = z.day;
	_hour = z.hour;
	_minute = z.minute;
	_second = z.second;
	_timestamp = z.timestamp;
	_weekday = z.weekday;
} 
DTime & DTime::operator=(const DTime & z) {
	_year = z.year;
	_month = z.month;
	_day = z.day;
	_hour = z.hour;
	_minute = z.minute;
	_second = z.second;
	_timestamp = z.timestamp;
	_weekday = z.weekday;
	return *this;
}

If you are agree, can you add the functions and create a new revision of the DTime class ?

Thanks a lot

-> Say me if you prefer me to do that

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions