Thread: Operator<<

  1. #1
    Unregistered
    Guest

    Question Operator<<

    Code:
    ostream& operator <<( ostream& os, const String& wrd )
    {
        os << wrd.str << endl;
        return os;
    }
    I am receiving the following err msg for my operator :

    Cannot create pre-compiled header: code in header
    Can anyone tell me what this means.

    Thanx
    Sophie

  2. #2
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    Turn off precompiled headers somewhere.
    Learn to use the search button dammit this has been asked a 100 times.

  3. #3
    Unregistered
    Guest
    If u use vc++, go to project->settings and from there c/c++ tab. there should be a precompiled header directives somewhere, click the 'Dont use precompiled header'
    Fixed!

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Turn it off??? Doesn't this error occur when you have other things than declarations in your header file (*.h), ie definitions?

    Declaration:
    void MyFunc(int, int);

    Definition:
    void MyFunc(int var1, int Var2)
    {
    ...
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. operator<< overload problem
    By stewie griffin in forum C++ Programming
    Replies: 5
    Last Post: 03-10-2009, 06:29 PM
  2. define operator<< for std::pair<string, int>
    By patiobarbecue in forum C++ Programming
    Replies: 2
    Last Post: 02-07-2009, 08:29 AM
  3. inheritance and operator<<
    By mickey0 in forum C++ Programming
    Replies: 39
    Last Post: 06-11-2008, 01:36 PM
  4. ostream operator<< () overload problems
    By jaybny in forum C++ Programming
    Replies: 2
    Last Post: 06-24-2006, 11:00 PM
  5. no match for 'operator<<' in.... Compile Problem!
    By njd in forum C++ Programming
    Replies: 5
    Last Post: 01-09-2006, 12:40 PM