Monday, September 22, 2008

C++ Questions ???

1. What are the four functions that compiler automatically provides? How can you prevent compiler to provide automatically?

>>

-
default constructor
- copy contructor
- assignment operator
- destructor

Friday, September 19, 2008

Friend in C++

In some circumstances, it is more convenient to grant member-level access to functions that are not members of a class or to all functions in a separate class. You can declare friend functions or friend classes to access not only public members but also protected and private class members.

The friend keyword allows a function or class to gain access to the private and protected members of a class.

Wednesday, September 17, 2008

Access Specifiers in C++

With C++, you can specify the level of access to member data and functions. There are three levels of access: public, protected, and private.

Access Specifiers:


Public : Available to everyone

Private : Class members declared as private can be used only by member functions and friends (classes or functions) of the class.
If someone tries to access a private member, they’ll get a compile-time error.

Protected : Class members declared as protected can be used by member functions and friends (classes or functions) of the class. Additionally, they can be used by classes derived from the class.