002 OOPs using C++ with Eclipse on LinuxDiscussion Forum for Programming with C++. We introduce to programming in general, including object-oriented programming and generic programming. It is also a solid introduction to the C++ programming language, one of the most widely used languages for real-world software. This Training presents modern C++ programming techniques from the start, introducing the C++ standard library to simplify programming tasks.
A derived class object can access the public and protected data, then what is the difference between public and protected data. I tried to use the public data without making the class derived but it fails with an error
For Ex:
class base{
private:
int b;
protected:
int p;
public:
base();
int pub;
};
class derived { // : public base{
private:
int d;
public:
derived();
void display()
{
//will cause error as not possible to access private data through derived class
//cout<<"Base class : Private:"<<b<<endl;
//cout<<"Base class : Protected:"<<p<<endl;
cout<<"Base class : Public:"<<(base :: pub)<<endl;