protected member OOP question
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 18

Thread: protected member OOP question

Threaded View

  1. #1
    Join Date
    Mar 2009
    Posts
    82

    Arrow protected member OOP question

    I got one question about protected members.

    Here is the code:
    Code:
    #include <iostream>
    
    using namespace std;
    
    class osnovna
    {
          protected:
          
          int test;
          
    };
    
    class izvedena : private osnovna
    {
    
    public:
    
           void funkcija()
           {
               cin>>test;
               
               cout<<test;
           }
    
    };
    
    class izvedena1 : public izvedena
    {
          
          public:
    
          void tesit()
          {
               cin>>test;
               
               cout<<test<<endl;
          }
    };
          
    int main()
    {
    
        izvedena dva;
        
        dva.funkcija();
        
        system("PAUSE");
    
        return 0;
        
    }
    Why when I write izvedena : public osnovna, or izvedena : protected osnovna the izvedena1 class can access the variable test and with private not?

    Can somebody elaborate please?

    Thanks in advance.
    Last edited by StGuru; June 28th, 2009 at 01:02 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center