Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Which print function going to be called. scope question.

Reply
Thread Tools

Which print function going to be called. scope question.

 
 
sasha
Guest
Posts: n/a
 
      04-15-2008
class Base{

public:
std:stream& operator<<( std:stream& os, const string &str )
{ return print(os); }

void print(stdstream& os){ os<<"Base\n";}
};


class Derived{
public:
using Base:perator<<;
void print(stdstream& os){ os<<"Derived\n";}
};

D d=Derived;
D<<"str";

B & pd=new Derived;
pd<<"str";


Notice that that print is not a virtual function.

I wonder if you bring base class member in the Derive class scope
and invoke it via Derived object, which print is it going to call: one
from derived or one from base.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
print(f) for files .. and is print % going away? Esmail Python 4 05-01-2009 02:42 AM
Re: print(f) for files .. and is print % going away? Esmail Python 2 05-01-2009 02:36 AM
Having trouble understanding function scope and variable scope Andrew Falanga Javascript 2 11-22-2008 09:23 PM
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments