istream help

This is a discussion on istream help within the C++ Programming forums, part of the General Programming Boards category; **FIXED** Im trying to pass this istream to my class and into a function, but doesnt work. I get this ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    110

    istream help

    **FIXED**

    Im trying to pass this istream to my class and into a function, but doesnt work. I get this error.


    error:

    'void PCall::get(std::istream &)' : overloaded member function not found in 'PCall'


    Im just eather tired of missing something small. Anyone wanna point me in the right direction?

    PCall class in pcall.h
    Code:
    #include <iostream.h>
    class PCall
    {
    public:
      void get(istream& in);
    
     };
    pcall.cpp
    Code:
    #include "pcall.h"
    #include <iostream.h>
    #include <string>
    using std::istream;
    using std::ifstream;
    using namespace std;
    
    void PCall::get(istream& in)
    {
        string currentCall;
        in >> currentCall;
            cout << currentCall << endl;
    }
    main.cpp
    Code:
      #include "pcall.h"
    #include <iostream.h>
    #include <fstream>
    #include <string>
    using std::istream;
    using std::ifstream;
    
    
    
    int main() 
    {
    PCall newCall;
    char fileName[16]; 
        cout << "Enter the input file name: ";
        cin.getline ( fileName,16, '\n' ); 
        ifstream inFile;
        inFile.open(fileName);
       newCall.get(inFile);
    
     return EXIT_SUCCESS;
    }
    Last edited by Coder87C; 02-18-2005 at 06:34 PM.

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    do I need to post more info>

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    do I need to post more info>
    How about posting your 'real' code. The reason I doubt that is your real code is twofold: there is no class called 'PhoneCall', and elsewhere you are using a variable name without having declared it, which the compiler would flag as an error.
    Last edited by 7stud; 02-18-2005 at 06:29 PM.

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    53
    Try to change get() to this:
    Code:
    std::istream& get(std::istream&);
    I think the OP only hid useless code which is the right thing to do. Oh and by the way, you should use iostream and not iostream.h and 0 is generally prefered (by convention) to EXIT_SUCCESS.
    Last edited by tilex; 02-18-2005 at 06:30 PM.

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    Quote Originally Posted by 7stud
    How about posting your 'real' code. The reason I doubt that is your real code is twofold: there is no class called 'PhoneCall', and elsewhere you are using a variable name without having declared it, which the compiler would flag as an error.

    Sorry, I had a million comments on testing code and went thru and try to clean it for forums, should be working now.

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    Quote Originally Posted by tilex
    Try to change get() to this:
    Code:
    std::istream& get(std::istream&);
    I think the OP only hid useless code which is the right thing to do. Oh and by the way, you should use iostream and not iostream.h and 0 is generally prefered (by convention) to EXIT_SUCCESS.

    iostream.h was my ENITRE problem. I run into this problem EVERY friggin time I use it and I forget and make a post or call a friend. Im getting a tattoo for my arm that says check iostream include

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. istream
    By Beowolf in forum C++ Programming
    Replies: 3
    Last Post: 10-30-2007, 06:11 PM
  2. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  3. istream overload
    By Trauts in forum C++ Programming
    Replies: 6
    Last Post: 05-06-2003, 09:29 PM
  4. istream >> overloading
    By wazza13 in forum C++ Programming
    Replies: 1
    Last Post: 05-03-2002, 11:56 PM
  5. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 04:07 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21