Click here to Skip to main content
15,903,856 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: help Pin
Richard MacCutchan25-Sep-15 22:09
mveRichard MacCutchan25-Sep-15 22:09 
AnswerRe: help Pin
Jochen Arndt24-Sep-15 22:30
professionalJochen Arndt24-Sep-15 22:30 
GeneralRe: help Pin
robsons200725-Sep-15 10:47
robsons200725-Sep-15 10:47 
GeneralRe: help Pin
robsons200725-Sep-15 10:57
robsons200725-Sep-15 10:57 
Questionc programm Pin
Honey1724-Sep-15 9:08
Honey1724-Sep-15 9:08 
AnswerRe: c programm Pin
k505424-Sep-15 9:26
mvek505424-Sep-15 9:26 
AnswerRe: c programm Pin
CPallini24-Sep-15 9:57
mveCPallini24-Sep-15 9:57 
GeneralRe: c programm Pin
Maximilien24-Sep-15 10:17
Maximilien24-Sep-15 10:17 
QuestionFunction parameter question Pin
econy23-Sep-15 7:42
econy23-Sep-15 7:42 
AnswerRe: Function parameter question Pin
David Crow23-Sep-15 7:58
David Crow23-Sep-15 7:58 
GeneralRe: Function parameter question Pin
Richard Andrew x6423-Sep-15 11:48
professionalRichard Andrew x6423-Sep-15 11:48 
GeneralRe: Function parameter question Pin
David Crow23-Sep-15 16:59
David Crow23-Sep-15 16:59 
GeneralRe: Function parameter question Pin
Richard MacCutchan23-Sep-15 21:38
mveRichard MacCutchan23-Sep-15 21:38 
AnswerRe: Function parameter question Pin
CPallini24-Sep-15 0:57
mveCPallini24-Sep-15 0:57 
Questionhelp Pin
robsons200722-Sep-15 16:17
robsons200722-Sep-15 16:17 
AnswerRe: help Pin
Richard Andrew x6422-Sep-15 18:15
professionalRichard Andrew x6422-Sep-15 18:15 
GeneralRe: help Pin
robsons200723-Sep-15 3:41
robsons200723-Sep-15 3:41 
SuggestionRe: help Pin
Richard MacCutchan22-Sep-15 21:04
mveRichard MacCutchan22-Sep-15 21:04 
QuestionCreating a thread in c Pin
mmapulac22-Sep-15 15:46
mmapulac22-Sep-15 15:46 
AnswerRe: Creating a thread in c Pin
Richard MacCutchan22-Sep-15 21:00
mveRichard MacCutchan22-Sep-15 21:00 
AnswerRe: Creating a thread in c Pin
David Crow23-Sep-15 2:34
David Crow23-Sep-15 2:34 
Questionthe drag of listview column don't work Pin
ProCodix21-Sep-15 14:59
ProCodix21-Sep-15 14:59 
AnswerRe: the drag of listview column don't work Pin
_Flaviu21-Sep-15 20:50
_Flaviu21-Sep-15 20:50 
QuestionHaving trouble with c++ templates Pin
BobInNJ21-Sep-15 12:48
BobInNJ21-Sep-15 12:48 
I have a c++ class that contains the following:

template<class T> class Poly {
public:
Poly<T>(int order = 0)
{
this->order = order;
coeffs = new double[order+1];
for( int i = 0;i<=order; i++ )
coeffs[i] = 0;
}
Poly<T>( int order, T *coeffs);
Poly<T>( Poly &poly );

~Poly()
{
delete []coeffs;
}

// other member functions are not shown.

friend ostream &operator << ( ostream &out,
Poly<T> &poly );
private:

// data members not show.

};

This class is defined in a file called poly.h. In the file poly.cpp, I have the following function definition:

template<class T>
ostream & operator << ( ostream &out, Poly<T> &poly )
{
bool printedCoeff = false;
.
.
.
return out;
}

In a third file called test.cpp, I have:

double coeffs[] = { 3, 1, 2, 1 };
Poly<double> p1(3,coeffs), p2;

cout << p1 << endl;

I am using the Microsoft Visual Studio and I get a linker error because of the statement:
cout << p1 << endl;

I believe that my definition of the function overloading << is
not properly getting instantiated. How do I fix this?

Bob
AnswerRe: Having trouble with c++ templates Pin
CPallini21-Sep-15 21:45
mveCPallini21-Sep-15 21:45 

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.