EECS 280 Lecture Notes - Lecture 8: In C, Information Hiding, Local Variable

56 views5 pages

Document Summary

All the members are by default private, in a struct they"re public. These are called member data and member functions. They"re controled with a this pointer (see example below); it always points to the particular instance of what we want to manipulate. We control who can get it and what. Public: //we specify that all these members are visible outside of the class. Double s = ( this->a + this->b + this->c )/2; Return sqrt(s = (s - this->a) (s - this->b) (s- this0>c) ); - you don"t have to explicitly write the this pointer, it"s usually there implicitly. In c, the area calculation had to be done outside of the struct adt; in c++, the function is a member of the class. In a class, we can use the dot notation to get member functions; when i call one of the members functions, it looks at the data as if it was a local variable.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents