CMPSC 32 Lecture Notes - Lecture 2: Access Control, In C, Call Site

32 views3 pages
7 Apr 2017
School
Course
Professor

Document Summary

Use dot operator to get members of an object. Object is to struct as instance is to class (to some degree) For struct, every member (ivar, method) is public. Smaller projects have less access control --> prefer struct. Example: struct date { int month; int day; int year; Safer operation x = p->x; p is a pointer. In c++, you would declare p without a * Usually allowed only for small structs that are passed around by value. Anything more complicated has private sections and possibly filters for setting p. x = 3 looks like plain assignment. The left hand side is called the lvalue. Could be a whole filter on that 3. Constructors are universally invoked by name of class or struct used like a function call. Can sometimes accomplish creating objects with the values you want with default variables in the declaration void func(int a, int b = 47);

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents