c++ - Multiple headers, how to use function on Object -


how access variable or typedef in header method? seems typedef isn't global though included header file, why?

i have following situation:

snake.h

#ifndef snake_h #define snake_h #include <utility>  class snake { public:      snake(int difficulty, int posx, int posy) : difficulty(difficulty) {         position.first = posx;         position.second = posy;     }     inline std::pair<int,int> const getposition() {         return position;     }  private:  typedef std::pair<int, int> point;     point position; };  #endif // !snake.h 

movement.cpp

#include "movement.h" #include "snake.h"  snake movedown() {      point dummy = snakeobject.getposition();     return .....; } 

now doesn't compile since there stuff missing, compiler fails recognize point type in movement.cpp file. also, need snake pointer in movement.h can use snake object call getposition?

i'm sorry vague description, appreciated.

point declared private class member, such not accessible non-class members.

either make public class member, use underlying std::pair type instead (like declared return type of method specifies), or assign return value auto.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -