I'm writing a program to do an organizational chart using linked lists. It has a class called "orgchart" which is the main chart. It consists of a bunch of functions plus a linked list of another class, "orgnode." The orgnode class is basically a generic "person" class, it has their title, name, and level in it. The five files in the program are orgchart.h (class definition), orgchart.cpp (class functions), orgnode.h (def), orgnode.cpp (functs), and final.cpp (the driver program).
I'm just starting it right now though, so it doesn't do much...except give me the strangest error I've ever seen.
orgchart.h
Code:
// orgchart.h: interface for the orgchart class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_ORGCHART_H__A2A5232E_84BD_4986_B7C9_B929B63F7A0B__INCLUDED_)
#define AFX_ORGCHART_H__A2A5232E_84BD_4986_B7C9_B929B63F7A0B__INCLUDED_
#include <iostream>
#include <string>
#include <list>
#include "orgnode.h"
using namespace std;
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class orgchart
{
public:
orgchart(string, string, int);
/* ostream &list(ostream &);
private:
list<orgnode> chart;
list<orgnode>::iterator current;
int counter;
void locate(int);
*/
};
#endif // !defined(AFX_ORGCHART_H__A2A5232E_84BD_4986_B7C9_B929B63F7A0B__INCLUDED_)
orgchart.cpp
Code:
// orgchart.cpp: implementation of the orgchart class.
//
//////////////////////////////////////////////////////////////////////
#include "orgchart.h"
#include "orgnode.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
orgchart::orgchart(string username, string usertitle, int userlevel)
{
orgnode node(username, usertitle, userlevel);
cout << node;
}
orgnode.h
Code:
// orgnode.h: interface for the orgnode class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_ORGNODE_H__990674FB_EED8_4ABB_9F06_FAE80C28AED3__INCLUDED_)
#define AFX_ORGNODE_H__990674FB_EED8_4ABB_9F06_FAE80C28AED3__INCLUDED_
#include <list>
#include <string>
using namespace std;
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class orgnode
{
friend ostream &operator<<(ostream &, orgnode &);
public:
orgnode(string, string, int);
string title;
string name;
int level;
};
#endif // !defined(AFX_ORGNODE_H__990674FB_EED8_4ABB_9F06_FAE80C28AED3__INCLUDED_)
orgnode.cpp
Code:
// orgnode.cpp: implementation of the orgnode class.
//
//////////////////////////////////////////////////////////////////////
#include "orgnode.h"
#include <list>
#include <string>
#include <iostream>
using namespace std;
orgnode::orgnode(string username, string usertitle, int userlevel)
{
name = username;
level = userlevel;
title = usertitle;
}
ostream &operator<<(ostream &output, const orgnode &node)
{
output << node.level << ": " << node.title << " (" << node.name << ")";
return output;
}
Finally, final.cpp
Code:
#include "orgnode.h"
#include "orgchart.h"
#include <iostream>
#include <string>
void main()
{
string username, usertitle;
int userlevel;
cout<<"Enter name"<<endl;
cin >> username;
cout <<"enter title"<<endl;
cin>>usertitle;
cout<<"enter level"<<endl;
cin>>userlevel;
orgchart chart(username, usertitle, userlevel);
}
The error (I'm not using a code tag here, because the table stretching would be terrible):
Compiling...
orgchart.cpp
Linking...
orgchart.obj : error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class orgnode &)" (??6@YAAAV?$basic_ostream@
DU?$char_traits@D@std@@@std@@AAV01@AAVorgnode@@@Z)
Debug/final.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
final.exe - 2 error(s), 0 warning(s)
I have no idea what that means. I don't even know where to begin. I feel bad for asking a lot of questions when I can answer only a few, but I'm really stuck here. Help would be appriciated.