Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C++ Templates+friends+operator overloading

Name: Anonymous 2010-11-11 18:11

Trying to overload << operator in templated class...this describes what happens and the solution along with explanation:
http://www.parashift.com/c++-faq-lite/templates.html#faq-35.16

Now what I don't understand is this :

"When you call the operator+ or operator<< functions, this assumption causes the compiler to generate a call to the non-template functions, but the linker will give you an "undefined external" error because you never actually defined those non-template functions."

Isn't this true for other functions as well? Like member functions? Why don't they generate a linker error?

Name: Anonymous 2010-11-11 18:42

>>1
The C++ Faq isn't the best place to search for answers. Try to consult your C++ Book, or the C++ FQA instead.

Name: Anonymous 2010-11-11 18:49

I have c++ primer and it does not answer the question.

Name: Anonymous 2010-11-11 18:51

no idea why it does it but you just have to do another template decleration right above the function using a different letter from what you used for your class

weird yes but sepples

Name: Anonymous 2010-11-11 22:09

>>4
bullshit

Name: Anonymous 2010-11-12 1:08

>>5
template<class T>
class fuck{

template<class P>
friend fuck(I forget if this needs one (>.<) KAWAIII!!!! ) operator +(fuck<P>)

Name: Anonymous 2010-11-12 1:22

<n00p> Zhivago: Because the stakeholders come up with requests and requirements. The stakeholder's requests are used to determine features
<Zhivago> n00p: Who were these stakeholders when they were inventing C?
<n00p> Zhivago: I don't actually know the answer to that question. Programmers for Unix?
<Zhivago> n00p: At some point some guy sat down and snorted a whole bunch of cocaine and came up with C's type syntax.
<Zhivago> n00p: What stakeholder issue drove that?

This except substitute ``C++templates'' for ``C type syntax''.

Name: Anonymous 2011-07-24 22:02

n00p is an annoying little turd who wishes he knew his lips from Zhivago's asshole

Name: Anonymous 2011-10-23 17:01

Zhivago is the most informative person ever. There is nothing Zhivago cannot explain.
            o                                            
                 O       /`-.__                          
                        /  \.'^|                         
           o           T    l  *                         
                      _|-..-|_                           
               O    (^ '----' `)     I HELP THE MENTALLY RETARDED PEOPLE
                     `\-....-/^      BECOME LESS STUPID WITH ZHIVAGO!
           O       o  ) "/ " (      /                    
                     _( (-)  )_                          
                 O  /\ )    (  /\                        
                   /  \(    ) |  \                       
               o  o    \)  ( /    \                      
                 /     |(  )|      \                     
                /    o \ \( /       \                    
          __.--'   O    \_ /   .._   \                   
         //|)\      ,   (_)   /(((\^)'\                  
            |       | O         )  `  |                  
            |      / o___      /      /                  
           /  _.-''^^__O_^^''-._     /                   
         .'  /  -''^^    ^^''-  \--'^                    
       .'   .`.  `'''----'''^  .`. \                     
     .'    /   `'--..____..--'^   \ \                    
    /  _.-/                        \ \                   
.::'_/^   |                        |  `.                 
       .-'|                        |    `-.              
 _.--'`   \                        /       `-.           
/          \                      /           `-._       
`'---..__   `.                  .`_.._   __       \      
         ``'''`.              .'##C   `'^  `''---'^      
                `-..______..-'

Don't change these.
Name: Email:
Entire Thread Thread List