# 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. ## 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|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.

Code:
```#ifndef 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...

2. 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,

Popular pages Recent additions