I am new to C++ and I think I may have thrown myself in a bit too deep!! I have programmed before in Delphi and Java so I think this may be more of a syntaxical problem.
I am trying to create a class and, on calling the constructor, pass a filename to the constructor. As it stands I'm trying to use a string variable.
The problem I get is that I get errors in my header and source file. In the header file, I get the error field 'string' has incomplete type. In my source file I have the error expected ')' before 'filename'.
The code I am using is below. Anyone got any ideas of the problem?
I'm using Eclipse if that helps anyone!
Bitmap.h
#ifndef BITMAP_H_
#define BITMAP_H_
namespace gary_media
{
class Bitmap
{
public:
Bitmap(string);
virtual ~Bitmap();
private:
int * image;
int imgHeight, imgWidth;
};
}
#endif /*BITMAP_H_*/
Bitmap.cpp
#include "Bitmap.h"
#include <cstdio>
#include <string>
//using namespace gary_file;
namespace gary_media
{
Bitmap::Bitmap(string filename)
{
if (filename == "") {
return;
}
if (!FileExists(filename)) {
return;
}
FILE * pFile;
pFile = fopen ("/home/gary/Desktop/test.txt", "r");
}
Bitmap::~Bitmap()
{
}
}
I am trying to create a class and, on calling the constructor, pass a filename to the constructor. As it stands I'm trying to use a string variable.
The problem I get is that I get errors in my header and source file. In the header file, I get the error field 'string' has incomplete type. In my source file I have the error expected ')' before 'filename'.
The code I am using is below. Anyone got any ideas of the problem?
I'm using Eclipse if that helps anyone!
Bitmap.h
#ifndef BITMAP_H_
#define BITMAP_H_
namespace gary_media
{
class Bitmap
{
public:
Bitmap(string);
virtual ~Bitmap();
private:
int * image;
int imgHeight, imgWidth;
};
}
#endif /*BITMAP_H_*/
Bitmap.cpp
#include "Bitmap.h"
#include <cstdio>
#include <string>
//using namespace gary_file;
namespace gary_media
{
Bitmap::Bitmap(string filename)
{
if (filename == "") {
return;
}
if (!FileExists(filename)) {
return;
}
FILE * pFile;
pFile = fopen ("/home/gary/Desktop/test.txt", "r");
}
Bitmap::~Bitmap()
{
}
}