cs246-s11-001-june23

cs246-s11-001-june23 - CS 246 (Spring 2011) Section 1...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 246 (Spring 2011) – Section 1 Thursday 23 June Encapsulation and System Modelling
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 246 (Spring 2011) - Section 001 - Thursday 23 June 2 Today's Agenda A few notes on pseudo-random numbers 2.21 Encapsulation 2.22 System Modelling
Background image of page 2
CS 246 (Spring 2011) - Section 001 - Thursday 23 June 3 Random Numbers (last class) class PRNG { uint32_t seed_ ; public: PRNG( uint32_t s = 362436069 ) { seed_ = s; } void seed( uint32_t s ) { seed_ = s; } uint32_t operator()() { // [0, UINT_MAX] seed_ = 36969 * (seed_ & 65535) + (seed_ >> 16); return seed_ ; } Using the same seed will generate the same sequence of pseudo-random numbers How to make this sequence “more random” ?
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 246 (Spring 2011) - Section 001 - Thursday 23 June 4 2.21 Encapsulation Encapsulation allows us to prevent access to members of a class by other classes Also known as access control Forces abstraction by hiding implementation Public members can be accessed anywhere Public routines sometimes called the “interface” Private or protected members are “off limits” to certain objects This is not a “necessary” part of software development So why are we doing it?
Background image of page 4
CS 246 (Spring 2011) - Section 001 - Thursday 23 June 5 Visibility labels Visibility labels indicate the level of access we allow to members within a class The first we will look at is public A public member in class C1 can be accessed by any other class or from within any routine All members within a struct are public by default
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/08/2011 for the course CS 246 taught by Professor Wormer during the Spring '08 term at Waterloo.

Page1 / 17

cs246-s11-001-june23 - CS 246 (Spring 2011) Section 1...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online