I want to declare a pointer in c++:
*************************************************************************
class MyAgent : public Agent
{
private:
int x,y;
int* xPtr;
int *yPtr;
void add();
public:
MyAgent(); // Declaration of constructor
};
MyAgent::MyAgent() : Agent(PT_UDP)
{
xPtr= &x;
yPtr= &y;
bind("x_otcl", &x);
bind("y_otcl", &y);
}
void MyAgent::add()
{
Tcl& tcl = Tcl::instance();
tcl.eval("puts \"From add() \"");
printf("\nx=%d and y = %d\nx+y = %d\n", x,y,x+y);
printf("xPtr=%d\n",*xPtr);
printf("yPtr=%d\n",*yPtr);
}
****************************************************************************
*
What is the difference between xPtr and yPtr? Is xPtr a pointer? Does the
compiler ignore the space? From the results, I figured that both of them are
pointers but I'm not sure. I always use the second one (yPtr) for
declaration of pointers.
Also please tell me how to bind pointers between c++ and otcl.
______________________________________________________
Reza Karimi, M.Sc.
Faculty of Electrical and Computer Engineering (ECE)
K.N.Toosi University of Technology
Tehran, IRAN.