Thread: Problem with header file method

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    100

    Problem with header file method

    Hey, I am getting these compiler errors:

    Code:
    15 bst.h variable or field `processInput' declared void 
    15 bst.h expected `;' before '(' token 
    14 bst.cpp no `void BST::processInput(std::ifstream&)' member function declared in class `BST'
    My code is:

    bst.h
    Code:
    #include <string>
    #include <fstream>
    
    #ifndef BST_H
    #define BST_H
    
    class BST
    {
        public:
            //BST(void);
            void processInput(ifstream & inSource);
    
    };
    
    #endif
    bst.cpp
    Code:
    #include <cstdlib>
    #include <iostream>
    #include <fstream>
    #include <string>
    #include "bst.h"
    
    using namespace std;
    
    void BST::processInput(ifstream & inSource)
    {
        string line;
    
        while(getline(inSource, line) != NULL)
            cout << line << "\n";
    }
    And the method is called by:
    Code:
    // error checking removed for length
    fileName = argv[1];
    
        fileStream.open(fileName);
    
        myBST.processInput(fileStream);
    Any help with the error?
    "I don't fail - I succeed at finding things that don't work"
    Website Promotion Techniques @AbstractPromotion.com

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Use std::ifstream in bst.h, or using namespace std.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. File Writing Problem
    By polskash in forum C Programming
    Replies: 3
    Last Post: 02-13-2009, 10:47 AM
  3. Need help understanding Header Files
    By Kaidao in forum C++ Programming
    Replies: 11
    Last Post: 03-25-2008, 10:02 AM
  4. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  5. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM