S
Sam
Hi I'm learning to code with C++ and wrote some very simple code. I
think it's consistent with every rule but always got compiling errors
that I don't understand.
The code include 5 files as following, delimited by //////:
////////////////pose.h
#ifndef pose_h
#define pose_h
#include "point.h"
class pose
{
int i;
public:
friend void point::init(pose P);
};
#endif
////////////////pose.cpp
#include "pose.h"
////////////////point.h
#ifndef point_h
#define point_h
#include "pose.h"
class point
{
public:
void init(pose P);
};
#endif
////////////////point.cpp
#include "point.h"
void point::init(pose P)
{
P.i=1;
}
////////////////main.cpp
#include "pose.h"
#include "point.h"
void main()
{
}
Basically the "point" class has a function to modify the "pose"
object's private data "i". VC++ always gives the error messages like:
'point' : is not a class or namespace name
'i' : cannot access private member declared in class 'pose'
syntax error : identifier 'pose'
nonexistent function 'point::init' specified as friend
I cannot understand it. Could anybody tell me what he thinks of it?
Thanks a lot.
think it's consistent with every rule but always got compiling errors
that I don't understand.
The code include 5 files as following, delimited by //////:
////////////////pose.h
#ifndef pose_h
#define pose_h
#include "point.h"
class pose
{
int i;
public:
friend void point::init(pose P);
};
#endif
////////////////pose.cpp
#include "pose.h"
////////////////point.h
#ifndef point_h
#define point_h
#include "pose.h"
class point
{
public:
void init(pose P);
};
#endif
////////////////point.cpp
#include "point.h"
void point::init(pose P)
{
P.i=1;
}
////////////////main.cpp
#include "pose.h"
#include "point.h"
void main()
{
}
Basically the "point" class has a function to modify the "pose"
object's private data "i". VC++ always gives the error messages like:
'point' : is not a class or namespace name
'i' : cannot access private member declared in class 'pose'
syntax error : identifier 'pose'
nonexistent function 'point::init' specified as friend
I cannot understand it. Could anybody tell me what he thinks of it?
Thanks a lot.