GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Jan-2005, 19:04
crq crq is offline
New Member
 
Join Date: Jan 2005
Posts: 15
crq is on a distinguished road

non-member function question


hey,

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  
Old 03-Feb-2005, 21:59
QED's Avatar
QED QED is offline
Member
 
Join Date: Feb 2005
Location: Hudson Valley, NY
Posts: 231
QED is a jewel in the roughQED is a jewel in the roughQED is a jewel in the rough

Will try to help if you can provide more info


I 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:
this template class with the object from the .h file is implemented in another class
Do you mean that it is an inner/nested class?

Matthew
 
 

Recent GIDBlogConfiguring iptables for Webmin Servers Index Module by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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 · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 07:23.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.