G
Guest
Hello:
Can we pass a pointer to an object from one cpp file to another by using a
function call. Assuming the object was created and declared along with its
accessor methods in the first cpp file, but you need to manipulate the same
object in the second cpp file.
heres a quick example of the function call which calls a function
in the second cpp file:
==================cpp #1
#include "cpp2.h"
class components
{
public:
void SYS_innitz_FLAG_AllTrueInCase() {}
virtual void SYS_set_SFCC(bool bCondTrue,int AmtOfComm) {}
protected:
};
static components cp;
SFC1(&cp); //Calling a function which exists in cpp #2
=======================
==================cpp2.h - header for cpp2
void SFC1(components *cp); //Function declaration
======================
==================cpp #2
void SFC1(components *cp) //Function implementation
{}
======================
When I do this I get the obvious errors of:
c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\XPPLC\SFC_1.h(19): error
C2065: 'components' : undeclared identifier
c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\XPPLC\SFC_1.h(19): error
C2065: 'cp' : undeclared identifier
It seems that all cpp files *must* have their own class definitions, and
associated implementations... right? I do beleive that I did post this
problem before at a much larger scale, however, there could be a wrinkle of
difference in this one. Basically, just double checking!
All welcome and appreciated for the feedback....
thanks!
Can we pass a pointer to an object from one cpp file to another by using a
function call. Assuming the object was created and declared along with its
accessor methods in the first cpp file, but you need to manipulate the same
object in the second cpp file.
heres a quick example of the function call which calls a function
in the second cpp file:
==================cpp #1
#include "cpp2.h"
class components
{
public:
void SYS_innitz_FLAG_AllTrueInCase() {}
virtual void SYS_set_SFCC(bool bCondTrue,int AmtOfComm) {}
protected:
};
static components cp;
SFC1(&cp); //Calling a function which exists in cpp #2
=======================
==================cpp2.h - header for cpp2
void SFC1(components *cp); //Function declaration
======================
==================cpp #2
void SFC1(components *cp) //Function implementation
{}
======================
When I do this I get the obvious errors of:
c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\XPPLC\SFC_1.h(19): error
C2065: 'components' : undeclared identifier
c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\XPPLC\SFC_1.h(19): error
C2065: 'cp' : undeclared identifier
It seems that all cpp files *must* have their own class definitions, and
associated implementations... right? I do beleive that I did post this
problem before at a much larger scale, however, there could be a wrinkle of
difference in this one. Basically, just double checking!
All welcome and appreciated for the feedback....
thanks!