iostream dissapears!

This is a discussion on iostream dissapears! within the C++ Programming forums, part of the General Programming Boards category; So I've got a project, called pong with these files. main.cpp include.h version.h otlv4.h i compile it and it works ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    40

    iostream dissapears!

    So I've got a project, called pong with these files.

    main.cpp

    include.h
    version.h
    otlv4.h

    i compile it and it works perfect.

    but when i add these two files

    keyinput.cpp
    keyinput.h

    iostream disapears!

    Code:
    C:\Users\Adam\Projects\Pong\include.h|12|error: iostream: No such file or directory|
    C:\Users\Adam\Projects\Pong\include.h|13|error: sstream: No such file or directory|
    C:\Users\Adam\Projects\Pong\include.h|14|error: fstream: No such file or directory|
    C:\Users\Adam\Projects\Pong\otlv4.h|978|error: new: No such file or directory|
    C:\Users\Adam\Projects\Pong\otlv4.h|1071|error: exception: No such file or directory|
    C:\Users\Adam\Projects\Pong\otlv4.h||In function 'otl_uncaught_exception':|
    C:\Users\Adam\Projects\Pong\otlv4.h|1075|error: 'std' undeclared (first use in this function)|
    C:\Users\Adam\Projects\Pong\otlv4.h|1075|error: (Each undeclared identifier is reported only once|
    ... the errors go on!
    here is whats in the files causing the problem.

    header
    Code:
    #ifndef KEYINPUT_CLASS_BY_ADAM
    #define KEYINPUT_CLASS_BY_ADAM
    
    #include "include.h"
    
    #define KEYPRESSED	0x1	// If key is pressed
    #define KEYNEW		0x2	// If keypress is new
    #define KEYREPEAT	0x4	// If an operating system repeat event is fired
    
    using namespace std;
    
    class KeyInput
    {
        public:
            KeyInput();
            ~KeyInput();
    
            void keydown(ALLEGRO_KEYBOARD_EVENT *kb);
    
    // If a key is released, mark it as unpressed
    // But if it was not yet processed, leave the keynew flag
            void keyup(ALLEGRO_KEYBOARD_EVENT *kb);
    
            // If an operating system repeat event comes in, set the flag
            void keyrepeat(ALLEGRO_KEYBOARD_EVENT *kb);
    
            // Called once per frame: removes the KEYNEW and KEYREPEAT status from all keys
            void keyupdate();
    
            // Empties the key buffer
            void keyclear();
        private:
            char    key[256];
    };
    
    #endif
    source
    Code:
    #include "KeyInput.h"
    
    using namespace std;
    
    void KeyInput::keydown(ALLEGRO_KEYBOARD_EVENT *kb)
    {  //what to do when a button was pressed
        key[kb->keycode] = KEYPRESSED | KEYNEW;
    }
    
    // If a key is released, mark it as unpressed
    // But if it was not yet processed, leave the keynew flag
    void KeyInput::keyup(ALLEGRO_KEYBOARD_EVENT *kb)
    {    //what to do when a key is released
            key[kb->keycode] &= ~KEYPRESSED;
    }
    
    // If an operating system repeat event comes in, set the flag
    void KeyInput::keyrepeat(ALLEGRO_KEYBOARD_EVENT *kb)
    {    //what to do when a key is held down
        key[kb->keycode] |= KEYREPEAT;
    }
    
    // Called once per frame: removes the KEYNEW and KEYREPEAT status from all keys
    void KeyInput::keyupdate()
    {  //reset all the data
        int i;
        static int val =  ((KEYNEW | KEYREPEAT) << 24) | ((KEYNEW | KEYREPEAT) << 16) | ((KEYNEW | KEYREPEAT) << 8) | KEYNEW | KEYREPEAT;
    
        for(i=0; i<64; i++) ((int*)key)[i] &= ~val;
    }
    
    // Empties the key buffer
    void KeyInput::keyclear()
    {
        memset(key, 0, sizeof(*key)*256);
    }
    and here is include.h incase your curious.

    Code:
    #ifndef INCLUDE_H_
    #define INCLUDE_H_
    
    #include <allegro5/allegro5.h>
    #include <allegro5/a5_iio.h>
    #include <allegro5/a5_font.h>
    #include <allegro5/a5_ttf.h>
    #include <allegro5/a5_primitives.h>
    #include <allegro5/acodec.h>
    #include <time.h>
    #include <stdlib.h>
    #include <iostream>
    #include <sstream>
    #include <fstream>
    #include "otlv4.h"
    
    #endif
    ive got no clue whats going on...

    EDIT:: for some reason changing KeyInput.cpp and .h to input.h and .cpp makes it work...
    Last edited by Adamkromm; 08-03-2009 at 08:55 PM. Reason: solved

  2. #2
    The Programming Dutchman
    Join Date
    Jan 2008
    Posts
    55
    if i use header files in my projects on the old fasion way (with the .h extentsion) i type:

    Code:
    #include <iostream.h>
    but most of the times i use:

    Code:
    #include <iostream>
    
    using namespace std;
    i an not familiar with your syntax of using .h files with the #include "headerfile.h" method, but give if a try.

    Good luck

    Jelte,
    The Programming Dutchman

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drieving from iostream
    By Thantos in forum C++ Programming
    Replies: 8
    Last Post: 06-23-2004, 04:57 PM
  2. iostream & hex?
    By dmlx90 in forum C++ Programming
    Replies: 0
    Last Post: 05-22-2002, 11:51 PM
  3. DJGPP Doesn't include IOSTREAM!!!!!!!!!!!
    By Frenchfry164 in forum Game Programming
    Replies: 12
    Last Post: 10-27-2001, 12:27 PM
  4. << in iostream
    By badman in forum C++ Programming
    Replies: 8
    Last Post: 10-18-2001, 10:19 PM
  5. Is there a C iostream?
    By Khisanth in forum C Programming
    Replies: 1
    Last Post: 09-05-2001, 12:34 AM

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