Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-02-2003, 04:17 PM   #1 (permalink)
Danish
Registered User
 
Join Date: Mar 2003
Posts: 12
Danish is on a distinguished road
Send a message via AIM to Danish
Linker errors on my linked list...

Okay, I'm trying to make my own templated linked list class (reinventing the wheel, but that's just a thing I do), and I want to be able to std::cout the nodes in said list. But, when I do, I get...

LinkedList.h:33: warning: friend declaration `std::ostream& operator<<(std::ostream&, const LinkedList<T>&)' declares a non-template function

Okay, let's fix that.

main.cpp:13: partial specialization `operator<< <T>' of function template

...

Well, let's just forgo the warning altogether.

C:\WINDOWS\TEMP/ccyRMggb.o(.text+0xa4):main.cpp: undefined reference to `operator<<(std::ostream&, LinkedList<int> const&)'

.........

Any ideas or hints? This isn't an assignment, I was just curious to see if I could do it.
Danish is offline   Reply With Quote
Old 03-02-2003, 07:59 PM   #2 (permalink)
Danish
Registered User
 
Join Date: Mar 2003
Posts: 12
Danish is on a distinguished road
Send a message via AIM to Danish
Hm...

Perhaps a little more detail. I'm using MinGW, and it appears that it doesn't like templates whose functions aren't defined in the file which is using them. And... that's bad because I want to define templated classes in their own files.

Any way around this?

Oh, yeah, and I abandoned the insertion operator overloading altogether and just did LinkedList::output() in the meantime. I'd still like to know how to fix either problem, though.

Thanks.

Okay, I'm getting a little better, now. I now have a functional templated linked list, but it's leaking memory left and right. Since I think this would be a good point to learn from, does anyone have any good gdb tutorials, particularly ones that could help me find memory leaks? I'm in way over my head, here, because google searches don't turn up anything useful and gdb itself isn't too helpful on learning how to use it. I'll see what I can learn in the meantime, though...
Danish is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A lil help with linked list Night_Prawler Standard C, C++ 2 08-11-2004 02:02 AM


All times are GMT -8. The time now is 03:49 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting