set03 - More on C+ Classes Jan. 2000 - ENEL 409 Dr. M....

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

View Full Document Right Arrow Icon
Jan. 2000 - ENEL 409 Dr. M. Moussavi 1 More on C++ Classes More on C++ Classes
Background image of page 1

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

View Full DocumentRight Arrow Icon
Jan. 2000 - ENEL 409 Dr. M. Moussavi 2 Class Scope Class Scope Every class maintains its own associated scope. If a variable at file scope has its name reused by a class member, that variable is hidden within the scope of the class. int x; // global x class A { int x; // member x hides global x public: void fun() { int x //hide global and member x } };
Background image of page 2
Jan. 2000 - ENEL 409 Dr. M. Moussavi 3 C++ functions - default C++ functions - default arguments arguments A function argument may have a default value. char fun (int h = 24, int w = 80, char ch = ‘ ‘); fun(); fun(2); fun(2, 8); fun(2, 8, ‘B’); The right most not initialized argument must be supplied with a default initializer before any argument to its left may be supplied. You should initialize arguments either at the function prototype or function definition, not both.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Jan. 2000 - ENEL 409 Dr. M. Moussavi 4 Friend functions and classes
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/10/2011 for the course ENEL 409 taught by Professor Moussavi during the Fall '11 term at University of Calgary.

Page1 / 13

set03 - More on C+ Classes Jan. 2000 - ENEL 409 Dr. M....

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

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