473,626 Members | 3,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

template problem with ostream operator (Borland compiler)

I am having a problem with the ostream operator in templated classes
that I wrote (I'm using the Borland compiler), and I'm certain that
the templates are the problem because when I remove the templating
completely everything works perfectly. Here is the error message:
Error: Unresolved external 'operator <<(std::basic_o stream<char,
std::char_trait s<char> >&, const BinomialTree<in t>&)' referenced from
C:\DOCUMENTS AND SETTINGS\RYAN\D ESKTOP\COMPUTER SCIENCE\CS
2413\PROJECTS\P ROJECT 3\TEMP\TMPPROJ3 .OBJ

And here is the relevant code:

template<class Object>
class BinomialTree
{
friend ostream& operator<< (ostream& stream, const
BinomialTree<Ob ject>& tree);

private:
//array of Binomial Node pointers
BinomialNode<Ob ject>* locations[100];

....more stuff
};

template<class Object>
ostream& operator<< (ostream& stream, const BinomialTree<Ob ject>&
tree)
{
for(int j = 0; j<100; j++)
{
if(tree.locatio ns[j] != NULL)
{
stream<<(*(tree .locations[j]));
}
}
return stream;
}

template <class Object>
class BinomialNode
{
//overloaded ostream operator, for displaying
friend ostream& operator<< (ostream& stream, const
BinomialNode<Ob ject>& node);

private:
void copy(const BinomialNode<Ob ject>& rhs);
Object _key;
int _degree;

BinomialNode* next; //pointer to the next node (a sibling)
BinomialNode* down; //the pointer to the child
BinomialNode* up; //the pointer to this node's parent

....more stuff
};

template<class Object>
ostream& operator<< (ostream& stream, const BinomialNode<Ob ject>&
node)
{
stream<<node._k ey;

if(node.down != NULL)
return stream<<(*(node .down));

else {

if(node.next == NULL)
return stream;
else
return stream<<(*(node .next));
}
}
Jul 19 '05 #1
0 2064

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5961
by: keit6736 | last post by:
Hi, I'm using the Borland compiler and I've created two templated classes in which I've overloaded the ostream << operator. However, when I try and use the operator on objects of either class I get the following error: Error: Unresolved external 'operator <<(std::basic_ostream<char, std::char_traits<char> >&, const BinomialTree<int>&)' referenced from C:\DOCUMENTS AND SETTINGS\RYAN\DESKTOP\COMPUTER SCIENCE\CS
2
10149
by: Christophe Barbe | last post by:
I posted a few days ago about the same problem but was not very clear. So here is my second take at it. Basically with GCC 3.3.2, I can't compile the example from the C++ FAQ Lite available online at http://www.parashift.com/c++-faq-lite/containers-and-templates.html#faq-34.15 Below are the two files that I compile with g++ foo.cpp -o foo or
6
2329
by: Adam Parkin | last post by:
Hello, all I'm having a problem with friend functions in a templatized Queue class I'm writing using linked lists. The problem is that I can't get the friend function to be able to access private data from the class. Here's the gist of the code: template <class T> struct NodeType { T data; NodeType<T> * link;
1
2221
by: paidojoao-groups | last post by:
Given this code: #include <iostream> #include <string> class timestamp { public: timestamp() {
5
1451
by: James Aguilar | last post by:
Hello, all. I saw this in the provided code of a lab that I have due in a couple of weeks in my algorithms class. It compiled fine in g++ but did not compile with the VC++ compiler. It does not recognize the angle brackets that follow "<<" in the operator friend declaration. --- CODE --- template <class T> class PriorityQueue {
7
1457
by: Jim Langston | last post by:
What I want to do is have an operator= accept a template variable. I will have some classes which all will contain an instance of a different class. I want an operator= in yet a 3rd class to accept these classes and use the instance. This is confusing as heck, so here's kinda what I want to do: class COffsetMap { public:
3
3748
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and thawed it out. I built a console app using Microsoft Visual C++ 6 (VC++) and it worked great. Only one line in the header file had to be commented out. I built a console app using Borland C++ Builder 5. The linker complained of references to...
0
1144
by: abelahcene | last post by:
Hi, Is it a bug ?? I tried to compile a cpp program which ran correctly on previous release (sarge debian, gcc compiler 3 ), it gave errors, for the declaration (even if I omit the symbols <) friend ostream & operator << <(ostream & os, Vector <T& tab); for other declaration ( not friend), the + operator, it works !! here is a complete example with errors at the compilation step. If I omit the << operator, the program will run
2
1970
by: syang8 | last post by:
Dear all, I am trying to design classes with stream support. Basically, I want the operator << work for the base class and all the derived classes. If the base class is a template class, and the operator << is also designed as a template function. The program has following linking errors: "error LNK2019: unresolved external symbol "class
0
8701
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6122
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1507
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.