Class, constructor and inherance.

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Oct 11 19:30:41 PDT 2015


On Monday, 12 October 2015 at 02:14:35 UTC, holo wrote:
> class credential
> {
> 	auto accessKey = environment.get["AWS_ACCESS_KEY"];
> 	auto secretKey = environment.get["AWS_SECRET_KEY"];
> }
>
> class sigv4 : credential
> {
> 	private:
> 		const algorithm = "AWS4-HMAC-SHA256";
>
> 		auto currentClock = Clock.currTime(UTC());
> 		auto currentDate = cast(Date)currentClock;
> 		auto curDateStr = currentDate.toISOString;
> 		auto currentTime = cast(TimeOfDay)currentClock;
> 		auto curTimeStr = currentTime.toISOString;
> 		auto xamztime = curDateStr ~ "T" ~ curTimeStr ~ "Z";
> }

You should set these in the constructor rather than in the class 
body (the only one that's okay to intialize here is `algorithm`, 
as it's a const string).




More information about the Digitalmars-d-learn mailing list