Click here to Skip to main content
15,881,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMessage sending in Lan C# win form Pin
123sudheer12313-Dec-12 19:19
123sudheer12313-Dec-12 19:19 
AnswerRe: Message sending in Lan C# win form Pin
Richard MacCutchan13-Dec-12 22:37
mveRichard MacCutchan13-Dec-12 22:37 
AnswerRe: Message sending in Lan C# win form Pin
Sajeesh Payolam14-Dec-12 2:31
Sajeesh Payolam14-Dec-12 2:31 
AnswerRe: Message sending in Lan C# win form Pin
vr99999999915-Dec-12 1:29
vr99999999915-Dec-12 1:29 
QuestionGraphics Interface (game) Pin
April Fans13-Dec-12 18:37
April Fans13-Dec-12 18:37 
AnswerRe: Graphics Interface (game) Pin
Richard MacCutchan13-Dec-12 22:40
mveRichard MacCutchan13-Dec-12 22:40 
GeneralRe: Graphics Interface (game) Pin
April Fans20-Dec-12 19:13
April Fans20-Dec-12 19:13 
QuestionCompilation Problem Pin
BobInNJ13-Dec-12 14:15
BobInNJ13-Dec-12 14:15 
C++
#include <iostream>
using namespace std;
template <class T> class Array {
  public:
    friend ostream& operator<< (ostream&, Array<T>&);

  private:
    T *pType;
};

template <class T>
ostream& operator<< (ostream& output, Array<T>& theArray)
{
   output << "output array" << endl;
   return output;
}
ostream& operator<< (ostream&, Array<int>&);
int main()
{
   Array<int> theArray;
   cout << theArray << endl;
   return 0;
}


I tried compiling the following code and I get a warning on line 5 that this statement declares a non-template function but despite this warning the code does compile. However, it does not link. The error message from the linker is:
/tmp/ccIbnsNk.o:t2.CFrown | :( text+0x9b): undefined reference to `operator<<(std::basic_ostream<char, std::char_traits<char=""> >&, Array<int>&)'

I feel the above code defines the function the linker says is undefined. What am I missing?

Bob
AnswerRe: Compilation Problem Pin
Graham Breach13-Dec-12 21:58
Graham Breach13-Dec-12 21:58 
GeneralRe: Compilation Problem Pin
BobInNJ14-Dec-12 11:16
BobInNJ14-Dec-12 11:16 
GeneralRe: Compilation Problem Pin
Graham Breach14-Dec-12 23:31
Graham Breach14-Dec-12 23:31 
Questionerror C2678: binary '=' Pin
alaaan7313-Dec-12 6:41
alaaan7313-Dec-12 6:41 
SuggestionRe: error C2678: binary '=' Pin
Maximilien13-Dec-12 7:00
Maximilien13-Dec-12 7:00 
GeneralRe: error C2678: binary '=' Pin
alaaan7313-Dec-12 7:18
alaaan7313-Dec-12 7:18 
AnswerRe: error C2678: binary '=' Pin
Chris Meech13-Dec-12 7:30
Chris Meech13-Dec-12 7:30 
GeneralRe: error C2678: binary '=' Pin
alaaan7313-Dec-12 7:52
alaaan7313-Dec-12 7:52 
GeneralRe: error C2678: binary '=' Pin
Chris Meech13-Dec-12 8:17
Chris Meech13-Dec-12 8:17 
GeneralRe: error C2678: binary '=' Pin
alaaan7313-Dec-12 8:59
alaaan7313-Dec-12 8:59 
GeneralRe: error C2678: binary '=' Pin
Chris Meech13-Dec-12 9:06
Chris Meech13-Dec-12 9:06 
GeneralRe: error C2678: binary '=' Pin
alaaan7313-Dec-12 9:24
alaaan7313-Dec-12 9:24 
GeneralRe: error C2678: binary '=' Pin
Freak3014-Dec-12 0:48
Freak3014-Dec-12 0:48 
AnswerRe: error C2678: binary '=' Pin
Richard MacCutchan13-Dec-12 7:33
mveRichard MacCutchan13-Dec-12 7:33 
GeneralRe: error C2678: binary '=' Pin
alaaan7313-Dec-12 7:55
alaaan7313-Dec-12 7:55 
Questionprocess Pin
messages13-Dec-12 3:45
messages13-Dec-12 3:45 
AnswerRe: process Pin
David Crow13-Dec-12 4:14
David Crow13-Dec-12 4:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.