[SOLVED] new to c++, two errors while compiling headers

Hi, i am new to c++, i am using code::blocks.
I was using Lazarus for object-pascal programming with a good knowledge but now i decided to learn c++, adding a challenge to my programming way.

Trying to port my .pas game to .cpp using SDL2 game engine.

header.h
1
2
3
4
5
class CTexture
{
public:
  SDL_Texture Load( string Dir );
}


header.cpp
1
2
3
4
5
6
SDL_Texture CTexture::Load( string Dir )
{
  ...
  // This function will load texture from disk ( i know how to do it, my problem is other)
  ...
}


Errors found:

In header.h
1
2
error: 'string' has not been declared
error: candidate is: SDL_Texture CTexture::Load(int)


In header.cpp
 
error: prototype for 'SDL_Texture CTexture::Load(std::string)' does not match any in class 'CTexture'


So.. what should i do!?
Please, help.
Thanks
Last edited on
Have you #included the header file required for the string class and how are you scoping the items in the std:: namespace?
In header.h
1
2
3
4
5
6
7
#ifndef HEADER_H_INCLUDED
#define HEADER_H_INCLUDED
#include "SDL.h"
#include "SDL_image.h"
#include <iostream>
#include <string>
#include <windows.h> 


In header.cpp
1
2
3
4
5
6
7
8
#include <iostream>
#include <string>
#include <windows.h>
#include "header.h"
#include "SDL.h"
#include "SDL_image.h"

using namespace std;


Hnm.. What is std:: namespace..?
Help

Hnm.. What is std:: namespace..?
Help

It is the namespace where all the standard C++ classes are defined. In your header you will need to properly scope these items.

header.h from above:
1
2
3
4
5
class CTexture
{
public:
  SDL_Texture Load( std::string Dir ); // Note the proper scoping for the std::string class.
}


Thanks.. but new error appeared on header.cpp
 
error: return type 'SDL_Texture { aka struct SDL_Texture}' is incomplete

Why?
Perhaps the following link might answer this question:

http://stackoverflow.com/questions/18897076/sdl-texture-incomplete-type
I just saw this post a bit before you answered me.. it now works! Thanks!
Topic archived. No new replies allowed.