Click here to Skip to main content
14,698,365 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: help Pin
robsons200723-Sep-15 4:41
Memberrobsons200723-Sep-15 4:41 
SuggestionRe: help Pin
Richard MacCutchan22-Sep-15 22:04
mveRichard MacCutchan22-Sep-15 22:04 
QuestionCreating a thread in c Pin
mmapulac22-Sep-15 16:46
Membermmapulac22-Sep-15 16:46 
AnswerRe: Creating a thread in c Pin
Richard MacCutchan22-Sep-15 22:00
mveRichard MacCutchan22-Sep-15 22:00 
AnswerRe: Creating a thread in c Pin
David Crow23-Sep-15 3:34
MemberDavid Crow23-Sep-15 3:34 
Questionthe drag of listview column don't work Pin
ProCodix21-Sep-15 15:59
MemberProCodix21-Sep-15 15:59 
AnswerRe: the drag of listview column don't work Pin
_Flaviu21-Sep-15 21:50
Member_Flaviu21-Sep-15 21:50 
QuestionHaving trouble with c++ templates Pin
BobInNJ21-Sep-15 13:48
MemberBobInNJ21-Sep-15 13: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 22:45
mveCPallini21-Sep-15 22:45 
QuestionCalling GDI+ DrawImage function throws _BLOCK_TYPE_IS_VALID error Pin
Kiran Satish21-Sep-15 8:39
MemberKiran Satish21-Sep-15 8:39 
AnswerRe: Calling GDI+ DrawImage function throws _BLOCK_TYPE_IS_VALID error Pin
CPallini21-Sep-15 22:50
mveCPallini21-Sep-15 22:50 
GeneralRe: Calling GDI+ DrawImage function throws _BLOCK_TYPE_IS_VALID error Pin
Jochen Arndt21-Sep-15 22:54
professionalJochen Arndt21-Sep-15 22:54 
GeneralRe: Calling GDI+ DrawImage function throws _BLOCK_TYPE_IS_VALID error Pin
CPallini21-Sep-15 23:01
mveCPallini21-Sep-15 23:01 
GeneralRe: Calling GDI+ DrawImage function throws _BLOCK_TYPE_IS_VALID error Pin
Jochen Arndt21-Sep-15 23:14
professionalJochen Arndt21-Sep-15 23:14 
QuestionShift + VK_LEFT Pin
_Flaviu20-Sep-15 22:44
Member_Flaviu20-Sep-15 22:44 
AnswerRe: Shift + VK_LEFT Pin
Jochen Arndt20-Sep-15 23:19
professionalJochen Arndt20-Sep-15 23:19 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu20-Sep-15 23:24
Member_Flaviu20-Sep-15 23:24 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu20-Sep-15 23:39
Member_Flaviu20-Sep-15 23:39 
GeneralRe: Shift + VK_LEFT Pin
Jochen Arndt20-Sep-15 23:51
professionalJochen Arndt20-Sep-15 23:51 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu21-Sep-15 0:04
Member_Flaviu21-Sep-15 0:04 
GeneralRe: Shift + VK_LEFT Pin
Jochen Arndt21-Sep-15 0:14
professionalJochen Arndt21-Sep-15 0:14 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu21-Sep-15 0:14
Member_Flaviu21-Sep-15 0:14 
GeneralRe: Shift + VK_LEFT Pin
Jochen Arndt21-Sep-15 0:21
professionalJochen Arndt21-Sep-15 0:21 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu21-Sep-15 0:23
Member_Flaviu21-Sep-15 0:23 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu21-Sep-15 23:13
Member_Flaviu21-Sep-15 23:13 

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.