GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 18-May-2006, 10:59
earachefl earachefl is offline
Member
 
Join Date: Feb 2006
Posts: 178
earachefl is on a distinguished road

Problems compiling an example


Sorry for the length of the following code, but I'm at a loss as to how much is important. I first tried inputting this example by hand from my textbook, then got the source code from the author's web site, which is what I am enclosing in its entirety. I get the following error messages:
Quote:
basic_string.h:2354: note: std::basic_istream<_CharT, _Traits>& std:perator>>(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
basic_string.h:2408: note: candidates are: std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&, _CharT) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
entry.cpp:73: note: std::istream& operator>>(std::istream&, entry&)
entry.cpp:76: error: no matching function for call to 'getline(std::basic_istream<char, std::char_traits<char> >&, std::string, char)'
entry.cpp:78: error: no match for 'operator>>' in 'ins >> entry::getNumber() const()'
istream:131: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
istream:134: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
istream:137: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
istream:169: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(bool&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:172: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(short int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:175: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(short unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:178: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:181: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:184: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(long int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:187: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(long unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:191: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(long long int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:194: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(long long unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:198: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(float&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:201: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(double&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:204: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(long double&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:207: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(void*&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:230: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]

Main:
CPP / C++ / C Code:
// FILE: TelDirecMenu.cpp
// MENU DRIVEN TELEPHONE DIRECTORY UPDATE PROGRAM

#include "indexList.h"
#include "entry.h"
#include <cctype>         // For toupper
#include <iostream>
#include <string>
using namespace std;

typedef indexList<entry, 100> telIndexList;

// Function prototype
   // PERFORMS USER SELECTION
   void select(telIndexList&, char);

int main()
{
   telIndexList telDirec;           // telephone directory
   char choice;                     // menu choice

   // Read the initial directory.
   cout << "Enter the initial directory entries -" << endl;
   telDirec.read(cin);

   // Keep reading and performing operations until user enters Q
   do
   {
      // Display the menu.
      cout << "Enter your choice -" << endl;
      cout << "A(Add), C(Change), D(Delete)," << endl 
           << "G(Get), S(Sort),   P(Print), Q(Quit): ";

      cin >> choice;
      cin.ignore(80, '\n');    // skip newline

      // Perform the operation selected.
      select(telDirec, choice);
   }
   while (toupper(choice) != 'Q');
   
   return 0;
}


// Performs user selection
void select(telIndexList& telDirec,  // INOUT : directory
            char choice)             // IN: selection
{
   // Local data
   entry anEntry;     // one entry
   string aName;      // input - entry name
   int index;         // index of name in directory
   char answer;       // input - indicates whether to add
                      //         entry for missing name

   switch (toupper(choice))
   {
      case 'A':   // Add an entry
         cout << "Enter entry to add - ";
         cin >> anEntry;
         telDirec.append(anEntry);
         break;

      case 'C':   // Change an entry
         cout << "Enter entry to change - ";
         cin >> anEntry;
         index = telDirec.search(anEntry);
         if (index >= 0)
            telDirec.replace(index, anEntry);
         else
         {
            cout << "Name not in directory. "
                 << "Do you wish to add it (Y or N): ";
            cin >> answer;
            if (toupper(answer) == 'Y')
               telDirec.append(anEntry);
         }
         break;

      case 'D':   // Delete an entry
         cout << "Enter name of entry to delete: ";
         //cin.ignore(1, '\n');
         getline(cin, aName, '\n');
         anEntry.setEntry(aName);
         index = telDirec.search(anEntry);
         if (index >= 0)
            telDirec.remove(index);
         else
            cout << "Entry not found - no deletion" << endl;
         break;

      case 'G':   // Get a number
         cout << "Enter name of entry to get: ";
         //cin.ignore(1, '\n');
         getline(cin, aName, '\n');
         anEntry.setEntry(aName);
         index = telDirec.search(anEntry);
         if (index >= 0)
         {
            telDirec.retrieve(index, anEntry);
            cout << "The number you requested is "
                 << anEntry.getNumber() << endl;
         }
         else
            cout << "Not in directory." << endl;
         break;

      case 'S':   // Sort directory
         telDirec.selSort();
         break;

      case 'P':   // Print directory
         telDirec.display();
         break;

      case 'Q':   // Quit directory
         cout << "Exiting program" << endl;
         break;

      default:
         cout << "Choice is invalid - try again" << endl;
         //cin.ignore(80, '\n');
   }
}  // end select

Entry.h:
CPP / C++ / C Code:
// File: entry.h
// Definition for a directory entry class

#include <iostream>
#include <string>
using namespace std;

#ifndef ENTRY_H
#define ENTRY_H

class entry
{
public:
   // Member functions
   // constructor
   entry();

   // Store data in an entry
   void setEntry(const string&, const string& nr = "");

   // accessor functions
   string getName() const;
   string getNumber() const;

   // operators
   //bool operator == (const entry&);
   friend bool operator == (const entry&, const entry&);
   bool operator <  (const entry&);
   bool operator >  (const entry&);

   // friends
   friend ostream& operator << (ostream&, const entry&);
   friend istream& operator >> (istream&, entry&);

private:
   string name;      // Person's name
   string number;    // and phone number
};

#endif  // ENTRY_H

entry.cpp:
CPP / C++ / C Code:
// File: entry.cpp
// Implementation file for class entry
 
#include "entry.h"
#include <iostream>
#include <string>
using namespace std;
 
// constructor
entry::entry()
{
   name = "";
   number = "";
}

// Store data in an entry
void entry::setEntry(const string& na,     // IN: name
                     const string& nr)     // IN: number
{
   name = na;
   number = nr;
}

// Get name
string entry::getName() const
{
   return name;
}

// Get number
string entry::getNumber() const
{
   return number;
}


// Operators 
/*
bool entry::operator == (const entry& dE)   // IN: right-operand
{
   return (name == dE.name);
}
*/
bool operator == (const entry& dE1, const entry&dE)   // IN: right-operand
{
   return (dE1.getName() == dE.getName());
}

bool entry::operator < (const entry& dE)   // IN: right-operand
{
   return (name < dE.getName());
}


bool entry::operator > (const entry& dE)   // IN: right-operand
{
   return (name > dE.getName());
}


// friends
ostream& operator << (ostream& outs,    // INOUT: stream
                      const entry& dE) 	// IN: entry displayed
{
   outs << "Name   is " << dE.getName() << endl;
   outs << "Number is " << dE.getNumber() << endl;

   return outs;
}


istream& operator >> (istream& ins, 	// INOUT: stream
                      entry& dE)   	// OUT: entry read
{
   cout << "Enter name: ";
   getline(ins, dE.getName(), '\n');
   cout << "Enter number: ";
   ins >> dE.getNumber();

   return ins;
}

indexList.h:
CPP / C++ / C Code:
// File: indexList.h
// Definition of indexed list template class

#ifndef INDEXLIST_H
#define INDEXLIST_H

#include <iostream>
using namespace std;

template <class T, int maxSize>
class indexList
{
public:
	// Constructor
	indexList();

	// Add an item to the end of an indexed list
	bool append(const T&);   // IN: item appended

	// Overwrite an element at a specified index
	bool replace(int,         // IN: insertion index
	             const T&);   // IN: item inserted

	// Insert an element at a specified index
	bool insert(int,         // IN: insertion index
	            const T&);   // IN: item inserted

        // Retrieve an element at a specified index
	bool retrieve(int,       // IN:  index
	              T&) const; // OUT: value retrieved

	// Delete an element at a specified index
	bool remove(int);        // IN: index

	// Find index of smallest value in a sublist
	int findMin(int,        // IN:  start index
	            int) const; // OUT: end index

	// Find index of largest value in a sublist
	int findMax(int,        // IN:  start index
 	            int) const; // OUT: end index

	// Find index of a target item
	//    Returns -1 if target item not found
	int search(const T&) const;  // IN: target item

	// Sort an indexed list
	void selSort();

	// Read data into the list
        void read(istream&);

	// Display the list contents
	void display() const;

	// Get the current size
	int getSize() const;

private:
	T elements[maxSize];  // Storage for elements
	int size;             // Count of elements in list
};

#endif  // INDEXLIST_H
indexList.cpp:
CPP / C++ / C Code:
// File: indexList.cpp
// Indexed list class implementation

#include "indexList.h"
#include <iostream>
using namespace std;

template <class T, int maxSize>
indexList<T, maxSize>::indexList()    // constructor
{
	size = 0;		// list is empty
}

// Add an item to the end of an indexed list
template <class T, int maxSize>
bool indexList<T, maxSize>::append(const T& item)

// Pre:  item is defined
// Post: if size < maxSize, item is appended to list
// Returns: true if item was appended; otherwise, false
{
	bool result;

	// Add item to the end of the list if list is not full.
	if (size < maxSize)
	{
		elements[size] = item;
		size++;
		result = true;
	}
	else
	{
		cerr << "Array is filled - can't append!" << endl;
		result = false;
	}
	return result;
}

// Replace an item at a specified index with a new one.
// Pre:  item and index are defined
// Post: item overwrites old item at position index if valid
// Returns: true if item was inserted; otherwise, false

template <class T, int maxSize>
bool indexList<T, maxSize>::replace(int index, const T& item)
{
	bool result;

	// Overwrite a list element if index is valid.
	if (index >= 0  &&  index < size)
	{
		elements[index] = item;
		result = true;
	}
	else
	{
		cerr << "Index " << index << " not in filled part"
			<< " - can't insert!" << endl;
		result = false;
	}
	return result;
}

template <class T, int maxSize>
bool indexList<T, maxSize>::insert(int index, const T& item)
{
	bool result;
        int i;

	// Insert a list element if index is valid.
	if (index >= 0  &&  index < size && size < maxSize)
	{
                // Shift elements down 1 position
                for (i = size - 1; i >= index; i--)
                    elements[i + 1] = elements[i];
		elements[index] = item;  // insert
                size++;
		result = true;
	}
	else
	{
		cerr << "Index " << index << " not in filled part"
			<< " - can't insert!" << endl;
		result = false;
	}
	return result;
}

// Retrieve an item at a specified index
// Pre:  item and index are defined
// Post: if index is valid, elements[index] is returned
// Returns: true if item was returned; otherwise, false

template <class T, int maxSize>
bool indexList<T, maxSize>::retrieve(int index, T& item) const
{
	bool result;

	// Return a list element through item if index is valid.
	if (index >= 0  &&  index < size)
	{
		item = elements[index];
		result = true;
	}
	else
	{
		cerr << "Index " << index << " not in filled part"
		     << " - can't retrieve!" << endl;
		result = false;
	}
	return result;
}

// Delete an element at a specified index
// Pre:  index is defined
// Post: if index is valid, elements[index] is replaced
//       with elements[size] and size is decremented.
// Returns: true if item was deleted; otherwise, false

template <class T, int maxSize>
bool indexList<T, maxSize>::remove(int index)

{
	bool result;
        int i;

	// Delete element at index i by moving elements up
	if (index >= 0  &&  index < size)
	{
		// Shift each element up 1 position
		for (i = index + 1; i < size; i++)
                   elements[i-1] = elements[i];
		size--;           // Decrement size
		result = true;
	}
	else
	{
		cerr << "Index " << index << " not in filled part"
		     << " - can't delete!" << endl;
		result = false;
	}
	return result;
}
/*
// Read data into the list
// Pre:  none
// Post: All data items are stored in array elements
//       and size is the count of items

template <class T, int maxSize>
void indexList<T, maxSize>::read(istream& ins)
{
	T nextItem;		// input - next data item

	size = 0;                // The list is empty.
        ins >> nextItem;
	while (!ins.eof() && size < maxSize)
        {
	   elements[size] = nextItem;
           size++;
           cout << "Enter next item - ";
           ins >> nextItem;
        }
}
*/

// Read data into the list
// Pre:  none
// Post: All data items are stored in array elements
//       and size is the count of items

template <class T, int maxSize>
void indexList<T, maxSize>::read(istream& ins)
{
	int numItems;	// input - number of items to read
	T nextItem;		// input - next data item

	cout << "Enter number of list items to read: ";
	ins >> numItems;
	ins.ignore(80, '\n');   // skip newline

	// If numItems is valid, read each list element,
	// starting with first element.
	size = 0;                // The list is empty.
	if (numItems >= 0  &&  numItems <= maxSize)
	   while (size < numItems)
	   {
	      cout << "Enter next item - ";
	      ins >> nextItem;
	      elements[size] = nextItem;
              size++;
	   }
	else
	   cerr << "Number of items " << numItems
           << " is invalid"
	        << " - data entry is cancelled!" << endl;
}

// Display the list contents
// Pre:  none
// Post: Displays each item stored in the list

template <class T, int maxSize>
void indexList<T, maxSize>::display() const
{
	// Display each list element.
	for (int i = 0; i < size; i++)
		cout << elements[i] << endl;
}


// Find index of a target item
// Pre:  none
// Post: Returns the index of target if found;
//         otherwise, return -1.

template <class T, int maxSize>
int indexList<T, maxSize>::search(const T& target) const
{
	for (int i = 0; i < maxSize; i++)
		if (elements[i] == target)
			return i;       // target found at position i

	// target not found
	return -1;
}


// Get the current size
template <class T, int maxSize>
int indexList<T, maxSize>::getSize() const
{
	return size;
}


// Sort the indexed list
template <class T, int maxSize>
void indexList<T, maxSize>::selSort()
{
	// Selection sort stub - do nothing
}



TIA to anyone who can help me sort this out.
  #2  
Old 18-May-2006, 11:16
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,032
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Problems compiling an example


I suggest you DON'T separate the implementation of the template class indexList into a .cpp file, but rather cut-paste it into the header, after the class declaration, and remove the indexList.cpp file from the project.

Please see Parashift on separating the definition of a template class from it's declaration to understand why this is needed.

Best regards,
Lucian
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #3  
Old 18-May-2006, 11:47
earachefl earachefl is offline
Member
 
Join Date: Feb 2006
Posts: 178
earachefl is on a distinguished road

Re: Problems compiling an example


Quote:
Originally Posted by LuciWiz
I suggest you DON'T separate the implementation of the template class indexList into a .cpp file, but rather cut-paste it into the header, after the class declaration, and remove the indexList.cpp file from the project.

Lucian,

I did try that in the example that I entered by hand. Taking your suggestion and pasting the implementation into the indexList.h file as so:

CPP / C++ / C Code:
// File: indexList.h
// Definition of indexed list template class

#ifndef INDEXLIST_H
#define INDEXLIST_H

#include <iostream>
using namespace std;

template <class T, int maxSize>
class indexList
{
public:
	
    indexList()    // constructor
    {
        size = 0;		// list is empty
    }

    // Add an item to the end of an indexed list
    bool append(const T& item)

    // Pre:  item is defined
    // Post: if size < maxSize, item is appended to list
    // Returns: true if item was appended; otherwise, false
    {
        bool result;

        // Add item to the end of the list if list is not full.
        if (size < maxSize)
        {
            elements[size] = item;
            size++;
            result = true;
        }
        else
        {
            cerr << "Array is filled - can't append!" << endl;
            result = false;
        }
        return result;
    }

    // Replace an item at a specified index with a new one.
    // Pre:  item and index are defined
    // Post: item overwrites old item at position index if valid
    // Returns: true if item was inserted; otherwise, false

    
    bool replace(int index, const T& item)
    {
        bool result;

        // Overwrite a list element if index is valid.
        if (index >= 0  &&  index < size)
        {
            elements[index] = item;
            result = true;
        }
        else
        {
            cerr << "Index " << index << " not in filled part"
                << " - can't insert!" << endl;
            result = false;
        }
        return result;
    }

    bool insert(int index, const T& item)
    {
        bool result;
            int i;

        // Insert a list element if index is valid.
        if (index >= 0  &&  index < size && size < maxSize)
        {
                    // Shift elements down 1 position
                    for (i = size - 1; i >= index; i--)
                        elements[i + 1] = elements[i];
            elements[index] = item;  // insert
                    size++;
            result = true;
        }
        else
        {
            cerr << "Index " << index << " not in filled part"
                << " - can't insert!" << endl;
            result = false;
        }
        return result;
    }

    // Retrieve an item at a specified index
    // Pre:  item and index are defined
    // Post: if index is valid, elements[index] is returned
    // Returns: true if item was returned; otherwise, false

    
    bool retrieve(int index, T& item) const
    {
        bool result;

        // Return a list element through item if index is valid.
        if (index >= 0  &&  index < size)
        {
            item = elements[index];
            result = true;
        }
        else
        {
            cerr << "Index " << index << " not in filled part"
                 << " - can't retrieve!" << endl;
            result = false;
        }
        return result;
    }

    // Delete an element at a specified index
    // Pre:  index is defined
    // Post: if index is valid, elements[index] is replaced
    //       with elements[size] and size is decremented.
    // Returns: true if item was deleted; otherwise, false

    
    bool remove(int index)

    {
        bool result;
            int i;

        // Delete element at index i by moving elements up
        if (index >= 0  &&  index < size)
        {
            // Shift each element up 1 position
            for (i = index + 1; i < size; i++)
                       elements[i-1] = elements[i];
            size--;           // Decrement size
            result = true;
        }
        else
        {
            cerr << "Index " << index << " not in filled part"
                 << " - can't delete!" << endl;
            result = false;
        }
        return result;
    }
    /*
    // Read data into the list
    // Pre:  none
    // Post: All data items are stored in array elements
    //       and size is the count of items

    
    void read(istream& ins)
    {
        T nextItem;		// input - next data item

        size = 0;                // The list is empty.
            ins >> nextItem;
        while (!ins.eof() && size < maxSize)
            {
           elements[size] = nextItem;
               size++;
               cout << "Enter next item - ";
               ins >> nextItem;
            }
    }
    */

    // Read data into the list
    // Pre:  none
    // Post: All data items are stored in array elements
    //       and size is the count of items

    
    void read(istream& ins)
    {
        int numItems;	// input - number of items to read
        T nextItem;		// input - next data item

        cout << "Enter number of list items to read: ";
        ins >> numItems;
        ins.ignore(80, '\n');   // skip newline

        // If numItems is valid, read each list element,
        // starting with first element.
        size = 0;                // The list is empty.
        if (numItems >= 0  &&  numItems <= maxSize)
           while (size < numItems)
           {
              cout << "Enter next item - ";
              ins >> nextItem;
              elements[size] = nextItem;
                  size++;
           }
        else
           cerr << "Number of items " << numItems
               << " is invalid"
                << " - data entry is cancelled!" << endl;
    }

    // Display the list contents
    // Pre:  none
    // Post: Displays each item stored in the list

    
    void display() const
    {
        // Display each list element.
        for (int i = 0; i < size; i++)
            cout << elements[i] << endl;
    }


    // Find index of a target item
    // Pre:  none
    // Post: Returns the index of target if found;
    //         otherwise, return -1.

    
    int search(const T& target) const
    {
        for (int i = 0; i < maxSize; i++)
            if (elements[i] == target)
                return i;       // target found at position i

        // target not found
        return -1;
    }


    // Get the current size
    
    int getSize() const
    {
        return size;
    }


    // Sort the indexed list
   
    void selSort()
    {
        // Selection sort stub - do nothing
    }



private:
	T elements[maxSize];  // Storage for elements
	int size;             // Count of elements in list
};

#endif  // INDEXLIST_H
gives me what looks to be similar errors:
Quote:
basic_string.h:2354: note: std::basic_istream<_CharT, _Traits>& std:perator>>(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
basic_string.h:2408: note: candidates are: std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&, _CharT) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
entry.cpp:73: note: std::istream& operator>>(std::istream&, entry&)
entry.cpp:76: error: no matching function for call to 'getline(std::basic_istream<char, std::char_traits<char> >&, std::string, char)'
entry.cpp:78: error: no match for 'operator>>' in 'ins >> entry::getNumber() const()'
istream:131: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
istream:134: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
istream:137: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
istream:169: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(bool&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:172: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(short int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:175: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(short unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:178: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:181: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:184: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(long int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:187: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(long unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:191: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(long long int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:194: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(long long unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:198: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(float&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:201: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(double&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:204: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(long double&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:207: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(void*&) [with _CharT = char, _Traits = std::char_traits<char>]
istream:230: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>:perator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]

While looking over the source code that the author provides, I noticed several discrepancies between it and the code given in the book. In particular, in the entry.h file , the line

CPP / C++ / C Code:
bool operator == (const entry&);

is provided in the source code as
CPP / C++ / C Code:
friend bool operator == (const entry&, const entry&);
; in the corresponding part of the implementation file, the entry
CPP / C++ / C Code:
bool entry::operator == (const entry&dE)   // IN: right-operand
{
   return (name == dE.name);
}
has been changed to this in the source code:
CPP / C++ / C Code:
bool operator == (const entry& dE1, const entry&dE)   // IN: right-operand
{
   return (dE1.getName() == dE.getName());
}
There are a number of other discrepancies that I see as well, at least another 7.
  #4  
Old 19-May-2006, 03:54
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,032
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Problems compiling an example


Well, by compiling the code in your first post, and performing the change I mentioned, I managed to compile, link and execute the program. It seems to me either the compiler you are using has some special issues, or the program uses some non-standard features, which are available on mine (VC++ 7.1). Or a combination of both.

I promise to take a better look at the code later today, unless you find the solution by then.
Could you please let me know which compiler you are using? If it is free, I can install it.

Best regards,
Lucian
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #5  
Old 19-May-2006, 05:46
earachefl earachefl is offline
Member
 
Join Date: Feb 2006
Posts: 178
earachefl is on a distinguished road

Re: Problems compiling an example


Quote:
Originally Posted by LuciWiz
Could you please let me know which compiler you are using? If it is free, I can install it.

Best regards,
Lucian

Hi Lucian,

I am using XCode 2.2.
  #6  
Old 19-May-2006, 05:56
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,032
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Problems compiling an example


Quote:
Originally Posted by earachefl
Hi Lucian,

I am using XCode 2.2.

I don't have a Mac
I meant to get one last Christmas, but it seemed to expensive, so I settled for a "regular" laptop.

OK, then I'll try to just think about the problem.

Lucian
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
Last edited by LuciWiz : 14-Jun-2006 at 06:37.
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems while burning CD's netnut Computer Software Forum - Windows 16 18-Jan-2008 00:45
C++ Compiling Error pointer MS Visual C++ / MFC Forum 3 12-May-2005 05:08
Error C2146: syntax error : missing ',' before identifier 'C4' mattchew008 C++ Forum 2 19-Dec-2004 07:06
kernel compiling & Geforce updating crystalattice Computer Software Forum - Linux 5 16-Jun-2004 08:38
Chaintech Geforce 5600 FX problems bartster74 Computer Hardware Forum 8 04-May-2004 14:16

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:29.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.