Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 631 posts ]  Go to page Previous  1 ... 46, 47, 48, 49, 50, 51, 52 ... 64  Next
Author Message
 Post Posted: July 18th, 2017, 3:27 pm 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3487
Location: Japan
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


Top 
 Profile  
Reply with quote  
 Post Posted: July 18th, 2017, 3:49 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 497
Location: Idiot from northern Europe
^ Oh yeah, linked list took a lot of trial and error even after reading a bunch :D

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.


Top 
 Profile  
Reply with quote  
 Post Posted: July 20th, 2017, 4:09 am 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3487
Location: Japan
One piece of advice: don't do this:

Code:
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


Top 
 Profile  
Reply with quote  
 Post Posted: July 20th, 2017, 6:45 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2844
Location: Oklahoma, United States
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


Top 
 Profile  
Reply with quote  
 Post Posted: July 20th, 2017, 2:54 pm 
 

Joined: June 26th, 2012, 5:38 pm
Posts: 766
Location: USA
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.


Top 
 Profile  
Reply with quote  
 Post Posted: July 20th, 2017, 6:05 pm 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2844
Location: Oklahoma, United States
@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


Top 
 Profile  
Reply with quote  
 Post Posted: July 21st, 2017, 8:49 am 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3487
Location: Japan
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


Top 
 Profile  
Reply with quote  
 Post Posted: July 21st, 2017, 2:58 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 497
Location: Idiot from northern Europe
^ 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.

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.


Top 
 Profile  
Reply with quote  
 Post Posted: July 23rd, 2017, 9:05 pm 
 

Joined: May 19th, 2016, 6:48 am
Posts: 34
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.


Top 
 Profile  
Reply with quote  
 Post Posted: July 24th, 2017, 9:32 am 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 497
Location: Idiot from northern Europe
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

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 631 posts ]  Go to page Previous  1 ... 46, 47, 48, 49, 50, 51, 52 ... 64  Next

Board index » Everything


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: