set03_1 - can be a friends to a class: A global function,...

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

View Full Document Right Arrow Icon
Jan. 2000 - ENEL 409 Dr. M. Moussavi 1 Friend Keyword in C++ Friend Keyword in C++
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 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 2
Jan. 2000 - ENEL 409 Dr. M. Moussavi 3 Friend functions and classes Friend functions and classes The following components of a program
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

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

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

Unformatted text preview: can be a friends to a class: A global function, visible by a class. A member function of other classes in the program, visible to the class. Another class. Jan. 2000 - ENEL 409 Dr. M. Moussavi 4 Friend Functions Friend Functions #include <iostream.h> void f(); class A{ int a; friend void f(); public: A( ); void print(); }; Jan. 2000 - ENEL 409 Dr. M. Moussavi 5 Friend Classes Friend Classes class B{ int b; friend class A; friend class C; public: B(); void print(); void f(); }; Jan. 2000 - ENEL 409 Dr. M. Moussavi 6 Friend Member Functions Friend Member Functions class C { friend void B::f(); int c; public: C( ); void print(); };...
View Full 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 / 6

set03_1 - can be a friends to a class: A global function,...

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