i am trying to load the morsecode.txt into my tree struct but when i compile it i keep getting this errors

error C2440: '=' : cannot convert from 'decode *' to 'int *'|

error C2664: 'bintree<dataType>::insert' : cannot convert parameter 1 from 'int' to 'const decode &'|

error C2676: binary '[' : 'bintree<dataType>' does not define this operator or a conversion to a type acceptable to the predefined operator|

error C2228: left of '.printDecode' must have class/struct/union|

#include <iostream> // Standard C++ Screen I/O
#include <fstream> // Standard C++ File I/O
#include <iomanip>
#include <string>
#include <vector>

#include "bintree.h"

using namespace std;
struct decode {
 /* decode struct to contain morse code data

      string alphabet;
      string code;

      decode() {
         alphabet = "";
         code = "";

      decode(const decode &other) :
         // copy constructor

      void setDecode(const string &name, int num) {
         alphabet = name;
         code = num;

      const string& getAlphabet() const {
         return alphabet;

     void printDecode(){
     cout <<fixed<<setprecision(2);
     cout <<setw(20)<<left<<alphabet<<setw(4)<<code<<"\n";

       bool operator == (const decode &rhs) const

      return (alphabet == rhs.alphabet);

   bool operator > (const decode &rhs) const

      return (alphabet> rhs.alphabet);

   bool operator < (const decode &rhs) const

      return (alphabet < rhs.alphabet);

      void loadDecode(ifstream &fin) {
         fin >> alphabet;
         fin >> code;


bool operator ==(const decode& lhs, const decode& rhs)


   return (lhs.alphabet == rhs.alphabet);


void loadDecode(bintree<decode> &decodes);
//void printEncode( vector<encode> &encodes);
void printDecode( bintree<decode> &decodes);

int main(int argc, char *argv[])
//   vector<encode> encodes;
   bintree<decode> decodes;

  // loadEncode(encodes);
 //  printEncode(encodes);

   return 0;

void loadDecode(bintree<decode> &decodes)
   ifstream fin;
   decode de;
int *prt;

   if (!fin) {
      cout << "Unable to read from "  <<

    while (!fin.eof()) {
    prt = new decode(de);
      decodes.insert(*prt);   //refer to lab 8
void printDecode( bintree<decode> &decodes)
   unsigned int i;

   for (i=0; i<decodes.size(); i++) {

Shouldn't you change from 'int *prt;' to 'decode *prt;' ?

Then you could change to

[B]ifstream &[/B] decode::loadDecode(ifstream &fin) 
    fin >> alphabet;
    fin >> code;

    return fin;

// ... and use it like

while (de.loadDecode(fin))
    prt = new decode(de);
    // you are not checking the result of allocation here,
    // if it failed, you are about to experience a crash ...
    decodes.insert(*prt);   //refer to lab 8

It's a very bad practice to use !fin.eof() within a while loop like, you are doing now.

commented: Good call on the use (and abuse) of eof() +16
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.