9-ClassesScopeResolution - / Class Scope #include...

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

View Full Document Right Arrow Icon
// Class Scope #include <iostream> using namespace std; // scope in a class object works differently than what we have // seen before in C and other C++ contexts. Normally, if we // want to make use of a variable or a function, that function // must have already have been defined, or prototyped before // we actually get to the function call. Same thing with a // variable, it too must have already been seen coming from // the top of the source code. // In an object, all the other parts of that object are // within that objects scope. So all of the class level // variables and functions can bee seen, regardless // of what order they appear in the class definition // C++ also allows us to strip apart the structure of the // class from the implementation of the class, as so: class TwoDRectangle { public: TwoDRectangle(); TwoDRectangle(int l, int w); int getLength(); int getWidth(); void setLength(int l); void setWidth(int w); void print(); long area(); private: int length; int width; }; // All of the functions are prototyped
Background image of page 1

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

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

This note was uploaded on 10/05/2011 for the course CS 37 taught by Professor Glenncuevas during the Summer '09 term at Irvine Valley College.

Page1 / 4

9-ClassesScopeResolution - / Class Scope #include...

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

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