[Dev-C++] A question about overloading
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Maya <Esc...@ne...> - 2003-11-25 17:54:50
|
In the parent class
~~~~~~~~~~~~~~~~~~~
class Parent{
public:
int a, b, c, d, e;
.....
template<class charT, class Traits>
friend std::basic_istream<charT, Traits>&
operator>> (std::basic_istream<charT, Traits>&, Parent&);
template<class charT, class Traits>
friend std::basic_ostream<charT, Traits>&
operator<< (std::basic_ostream<charT, Traits>&, Parent& );
In the chile class
~~~~~~~~~~~~~~~~~~
class Chile : virtual public Parent{
public:
int f,g;
......
template<class charT, class Traits>
friend std::basic_istream<charT, Traits>&
operator>> (std::basic_istream<charT, Traits>&,Chile&);
template<class charT, class Traits>
friend std::basic_ostream<charT, Traits>&
operator<< (std::basic_ostream<charT, Traits>&, Chile& );
As you can see, the derived class also has a inserter and an extractor
overloaded operator. However, in the driver program [main.cpp] I want to
make a call to the overloaded inserter and extractor from the Parent
class, but don't know how to go about it!
void main(){
Chile obj;
obj.a = 1; obj.b = 2; obj.c = 3; obj.d = 4; obj.e = 5; obj.f = 6;
obj.g = 7;
...
std::cout << obj << std::endl; // which inserter is called here?
}
--
Jorge Escalante
FYI
http://www.astro.umd.edu/~marshall/abbrev.html
E-Mail Policy
http://www.vif.com/users/escalante/Email_Policy.html
* You cannot exercise your power to a point of humiliation.
- Jean Chretien
* The media's the most powerful entity on earth. They have the
power to make the innocent guilty and to make the guilty
innocent, and that's power.
- Malcom X
* "Innocent until proven guilty", no... not in Canada!!
|