U
uche
Hello, I am having a problem with my code in C++/C. I have struggled
for a while and cannot find the solution to the problem...
Here is the compiled..output:
In file included from disk.cpp:8:
disk.h:31:2: invalid preprocessing directive #inlcude
In file included from disk.cpp:8:
****disk.h:89: error: 'ifstream' is used as a type, but is not defined
as a type.*****
In file included from /usr/include/c++/3.3/backward/iostream.h:31,
from disk.cpp:11:
/usr/include/c++/3.3/backward/backward_warning.h:32:2: warning:
#warning This file includes at least one deprecated or antiquated
header. Please consider using one of the 32 headers found in section
17.4.1.2 of the C++ standard. Examples include substituting the <X>
header for the <X.h> header for C++ includes, or <sstream> instead of
the deprecated header <strstream.h>. To disable this warning use -Wno-
deprecated.
disk.cpp: In member function `bool Cdisk:pen(const char*)':
disk.cpp:16: error: `file_in' undeclared (first use this function)
disk.cpp:16: error: (Each undeclared identifier is reported only once
for each
function it appears in.)
....sample code:
==================================================
#ifndef DISK_H
#define DISK_H
#include <cstdlib>
#include <iomanip>
#include <iostream>
#inlcude <fstream>
class Cdisk
{
public:
bool open(const char* filename);
bool eof() const;
int read(char* buffer, int length); // get_byte
bool seek(int position);
int tell() const;
void close();
ifstream file_in;
};
==================================================
//disk.cpp
#include "disk.h"
#include <cstdlib>
#include <iomanip>
#include <iostream.h>
#include <fstream>
bool Cdisk:pen(const char* filename)
{
file_in.open(filename, ios::binary);
if (!file_in)
{
printf("Fail to Open\n");
return false;
}
return true;
}
bool Cdisk::eof() const
{
if (file_in.eof())
return 1;
return 0;
}
int Cdisk::read(char* buffer, int length)
{
file_in.read(buffer,length);
return file_in.gcount();
}
bool Cdisk::seek(int position)
{
long pos;
long file_beg, file_end;
long file_size;
pos = fseek(file_in, position, 0);
if (pos == 0 || pos <= 511)
return true;
return false;
}
int Cdisk::tell() const
{
return file_in.tellg();
}
void Cdisk::close()
{
file_in.close();
}
========
for a while and cannot find the solution to the problem...
Here is the compiled..output:
In file included from disk.cpp:8:
disk.h:31:2: invalid preprocessing directive #inlcude
In file included from disk.cpp:8:
****disk.h:89: error: 'ifstream' is used as a type, but is not defined
as a type.*****
In file included from /usr/include/c++/3.3/backward/iostream.h:31,
from disk.cpp:11:
/usr/include/c++/3.3/backward/backward_warning.h:32:2: warning:
#warning This file includes at least one deprecated or antiquated
header. Please consider using one of the 32 headers found in section
17.4.1.2 of the C++ standard. Examples include substituting the <X>
header for the <X.h> header for C++ includes, or <sstream> instead of
the deprecated header <strstream.h>. To disable this warning use -Wno-
deprecated.
disk.cpp: In member function `bool Cdisk:pen(const char*)':
disk.cpp:16: error: `file_in' undeclared (first use this function)
disk.cpp:16: error: (Each undeclared identifier is reported only once
for each
function it appears in.)
....sample code:
==================================================
#ifndef DISK_H
#define DISK_H
#include <cstdlib>
#include <iomanip>
#include <iostream>
#inlcude <fstream>
class Cdisk
{
public:
bool open(const char* filename);
bool eof() const;
int read(char* buffer, int length); // get_byte
bool seek(int position);
int tell() const;
void close();
ifstream file_in;
};
==================================================
//disk.cpp
#include "disk.h"
#include <cstdlib>
#include <iomanip>
#include <iostream.h>
#include <fstream>
bool Cdisk:pen(const char* filename)
{
file_in.open(filename, ios::binary);
if (!file_in)
{
printf("Fail to Open\n");
return false;
}
return true;
}
bool Cdisk::eof() const
{
if (file_in.eof())
return 1;
return 0;
}
int Cdisk::read(char* buffer, int length)
{
file_in.read(buffer,length);
return file_in.gcount();
}
bool Cdisk::seek(int position)
{
long pos;
long file_beg, file_end;
long file_size;
pos = fseek(file_in, position, 0);
if (pos == 0 || pos <= 511)
return true;
return false;
}
int Cdisk::tell() const
{
return file_in.tellg();
}
void Cdisk::close()
{
file_in.close();
}
========