![]() |
|
#1
|
|||
|
|||
non-member function questionhey,
i have a .h class that has a class declaration with 2 data members (both public ... ick ick ... my prof wants us to do it that way, though). it also has 2 overloaded operator public functions == and !=. after that declaration is over }; there are two non-member function overloaded operators for << ostream and >> istream. and that is all ... this class is to be the type of a template class. this template class (consisting of those two data members), ALSO has an overloaded << ostream that is a non-member function. now this template class with the object from the .h file is implemented in another class with (you guessed it) a friend << ostream operator. my first question is this ... will you ever be able to USE the overloaded operators << and >> from the .h file since they are not a part of the class? non-member functions wouldn't go with a declaration of that class in another class would they? second question is this ... will you ever use the non-member function overloaded << ostream in the template class? third question ... why is it ok to use these as non-member functions without having to do the "friend" thing in the .h and the template? is it because they aren't part of a class? or is it because of a public/private access thing? fourth question ... does the << have to be a friend to access "protected" data members? in the template class, the << ostream overload function is a non-member but needs to access the protected data members of that class. thanks crq |
|
#2
|
||||
|
||||
Will try to help if you can provide more infoI would like to help, but am having a tough time understanding the details of your problem. First of all, please post a code sample; it will make it much easier for anyone that would like to help you out.
Second, what do you mean that the first class declaration has two data members, and the second template class "consists of those data members?" Third, I don't know what you mean by the phrase "implemented in another class" in the context used... Quote:
Matthew |
Recent GIDBlog
Toyota - 2008 July Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| [Tutorial] GUI programming with FLTK | dsmith | FLTK Forum | 10 | 03-Oct-2005 15:41 |
| pointer to a member function | small_ticket | C++ Forum | 3 | 10-Jan-2005 07:23 |
| Revising Script style ?????? | pepee | MySQL / PHP Forum | 4 | 14-Apr-2004 04:59 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The