Problem with a class

I have a class Text:

1
2
3
4
5
6
//text.h
class Text
{
public:
  write_blended(/*something*/) {/*function definition*/ }
};


and a class Game:

1
2
3
4
5
6
7
8
//game.h
#include "text.h"
class Game
{
public:
  Text text;
  Game();
}


1
2
3
4
5
6
//game.cpp
#include "game.h"
Game::Game()
{
  text.write_blended(/*something*/);
}


After writing all this I add a function size() to Text and change Game::Game() to:

1
2
3
4
5
Game::Game()
{
  text.write_blended(/*something*/)
  text.size();
}


I get an error 'class Text' has no member named 'size'. I've tried rebuilding the code from scratch but to no avail.

Any ideas?
Last edited on
Uh... What?

The only method in Text is write_blended(). The compiler can't call a function you haven't defined.
After writing all this I add a function size() to Text
Looks like you missed a line, or may be I wasn't clear enough.

I define another function Text::size() in Text and then change Game::Game() to:
1
2
3
4
5
Game::Game()
{
  text.write_blended(/*something*/)
  text.size();
}
Okay, so you defined it, but did you declare it in the header?
The function is defined in the header.
1
2
3
4
5
6
7
//text.h
class Text
{
public:
  void write_blended(/*something*/) {/*function definition*/ }
  void size() { /*definition*/ }
};

I'm beginning to think this might be a problem with my IDE. An attempt optimize compilation time perhaps. I'm going to try Dev C++
Yup, it was an IDE problem. Fixed.
Topic archived. No new replies allowed.