codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  protected access/inheritance  craigb at 21:50 on Thursday, August 18, 2005
 

I have a question about access control in C++:

// base.h

class base
{
protected:
virtual int f() { return -1; }
};

--------------------------------------------------------------------

// derived.h

class derived : public base
{
private:
base* b;
protected:
virtual int f() {
b = new base();
return b->f();
}
};


--------------------------------------------------------------------

This doesn't compile. Why not? How can I call b's version of f()?

Thanks!

  Re: protected access/inheritance  Yusairi at 04:18 on Friday, August 26, 2005
 

A member (either data member or member function) declared in a protected section of a class can only be accessed by member functions and friends of that class, and by member functions and friends of derived classes
Yusairi: site expert
http://www.codetoad.com









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
• C++
• Re: refresh parent after closing pop up window
• Dynamic Insertion
• Date and Time function around the world???
• Significant Factors
• Perl array access
• Re: huffman encoding and decoding in C++...
• Perl One Liner: Replace {(
• Re: html including php, accessing the functions


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009