Noob learns to code in 3 months

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Noob learns to code in 3 months

Post by chili » July 18th, 2017, 3:27 pm

Well, better to feel confused than to have a false sense of mastery, that's my philosophy. You must have absorbed a fair bit of the lesson if you managed to get the container to work without leaking any memory. Good job on figuring out linked lists on your own as well. That part is at least as difficult as the deep copy/rule of 3 stuff.
Chili

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » July 18th, 2017, 3:49 pm

^ Oh yeah, linked list took a lot of trial and error even after reading a bunch :D

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Noob learns to code in 3 months

Post by chili » July 20th, 2017, 4:09 am

One piece of advice: don't do this:

Code: Select all

this->~Stack();
I see where the temptation comes in, but if you really want to do code reuse (a good impulse/desire), do like papa did and make a separate private member function for freeing resources and call it from your dtor/copy assign/etc.
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Noob learns to code in 3 months

Post by albinopapa » July 20th, 2017, 6:45 am

Hey Chili, Is there ever a case for NEEDING to call the dtor directly?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

cameron
Posts: 794
Joined: June 26th, 2012, 5:38 pm
Location: USA

Re: Noob learns to code in 3 months

Post by cameron » July 20th, 2017, 2:54 pm

Well, I am not chilli but... if you ever want to fool around with writing construct/destruct functions similar to new/delete you gotta. (or perhaps overloading....)
Computer too slow? Consider running a VM on your toaster.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Noob learns to code in 3 months

Post by albinopapa » July 20th, 2017, 6:05 pm

@cameron: I'm assuming you'd want to write those for a custom allocator, correct?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Noob learns to code in 3 months

Post by chili » July 21st, 2017, 8:49 am

Yup I was gonna say something similar.

Actually, when you use shared_ptr with make_shared, the control block and the payload object are allocated with a single heap allocation, so I believe the internal implementation calls dtor when the use count reaches 0 (so the object can free its resources), and then frees the combined payload/control block heap memory when both the use count and the weak count are 0.

And like cam says, any kind of custom allocation is gonna require your calling the dtor directly, as well as in-place construction I guess.
Chili

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » July 21st, 2017, 2:58 pm

^ I'm barely following you guys:P

I got held up a couple of days due to sleeping issues leaving me tired all day + trying to write a wedding speech for my brother. But now I've watched the video about matrices and rewatched the video about rotation and am going to open up the math book today.

Byteraver
Posts: 60
Joined: May 19th, 2016, 6:48 am
Location: Belgium, Europe

Re: Noob learns to code in 3 months

Post by Byteraver » July 23rd, 2017, 9:05 pm

I'm a bit late to the discussion but I found Khan's Academy (https://www.khanacademy.org/) extremely useful to review trigonometry, functions and matrices (math in general). He explains it very well and the exercises help to anchor the knowledge firmly. It took me a few months worth of evening study to review it all but definitely helped whilst programming my breakout / arkanoid clone somewhat later.

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » July 24th, 2017, 9:32 am

Byteraver wrote:I'm a bit late to the discussion but I found Khan's Academy (https://www.khanacademy.org/) extremely useful to review trigonometry, functions and matrices (math in general). He explains it very well and the exercises help to anchor the knowledge firmly. It took me a few months worth of evening study to review it all but definitely helped whilst programming my breakout / arkanoid clone somewhat later.
Awesome! Will check it out once I'm done with the book to go into more details. The book I'm reading is more of an overview of the subject.

Finished the fundamentals part which briefly explained
- complex numbers
- implications and equicalence
- set theory
- functions, onto, one-to-on and inverse
- linear transformations

next 2 chapters are matrices and the 2 after that are vectors followed by Linear transformations and eigenvalues and eigenvectors.

Will try to look into all these subjects on khan afterwards

Post Reply