Sign in to follow this  
monkrydaz

Class problems

Recommended Posts

Been Trawling the internet for hours and still can't solve the problem. I've decided to seperate all my headers into .h and .cpp as I understand this is the norm. (Before all the code was in just .h) Everytime I compile the below code I get the following error;
error C2065: 'imageData' : undeclared identifier

I've tried using extern (although im not totally sure how to use it-any help?) manage_image.h
#ifndef MANAGE_IMAGE_H
#define MANAGE_IMAGE_H 

#include <vector>
#include <string>
#include "image.h"


class manage_image
{
private:
	std::vector<image*> imageData;

public:
	manage_image(void);
	~manage_image(void){};
	int addImage(std::string FileName);
	BYTE* getAddress(int getID);

};




manage_image.cpp
#include "manage_image.h"

#include "image.h"
#include <vector>


manage_image::manage_image(void)
{
}

int addImage(std::string FileName)
{
	int returnID = imageData.size();


	image *AddressToAdd = new image(FileName);
	imageData.push_back(AddressToAdd);


	return returnID;
}
BYTE* getAddress(int getID)
{
	return imageData[getID]->GetPointer();

}


Can anybody help point out the problem and how to solve it. Thanks. Darren PS Sorry about that seemed to have posted in the game programming forum instead of general programming

Share this post


Link to post
Share on other sites
In the CPP file, the compiler doesn't know that it is part of manage_image.h, just that you include it.

The addImage method should go: int manage_image::addImage.

The manage_image:: tells the compiler that addImage is part of the included manage_image class.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this