class A { }
class B : public A {
doSomething {
C * c = new C(this);
}
}
class C
{
C(A* copy);
}
In the following example I get the following error:
error: no matching function for call to `C::C(B* const)'
I wan't to get the A pointer in the this call but for some reason I can't get this through. Probably some silly typo but as it's Rhapsody generated I don't really feel I have the control over why I get this issue when compiling.
Trying to add another headerfile. It wont compile as it's so many files that needs to be included but this is the actual code (changed class names) that is executed and the underlying classes is working.
#ifndef A_H
#define A_H
//## auto_generated
#include <oxf/oxf.h>
//## auto_generated
#include "TestSequencePkg.h"
//## auto_generated
#include <oxf/omreactive.h>
//## auto_generated
#include <oxf/state.h>
//## auto_generated
#include <oxf/event.h>
//## class A
#include "D.h"
//## dependency F
#include "F.h"
//## class A
#include "C.h"
//## dependency G
#include "G.h"
//## class A
#include "B.h"
//## class A
#include "E.h"
//## operation A(TestContextC *)
class TestContextC;
//## package TestSequencePkg
//## class A
class A : public OMReactive, public B, public C, public D, public E {
//// Constructors and destructors ////
public :
//## operation A(TestContextC *)
A(TestContextC * context, IOxfActive* theActiveContext = 0);
//## auto_generated
A(IOxfActive* theActiveContext = 0);
//## operation ~A()
~A();
//// Operations ////
//## operation handleInMessage(AFBaseMsgC *)
virtual ACE_UINT32 handleInMessage(AFBaseMsgC * msg);
//## operation init()
virtual void init();
//// Additional operations ////
//## auto_generated
virtual bool startBehavior();
protected :
//## auto_generated
void initStatechart();
//// Framework operations ////
public :
// rootState:
//## statechart_method
inline bool rootState_IN() const;
//## statechart_method
inline bool rootState_isCompleted();
//## statechart_method
virtual void rootState_entDef();
//## statechart_method
void rootState_exit();
//## statechart_method
virtual IOxfReactive::TakeEventStatus rootState_processEvent();
// UpdateData:
//## statechart_method
inline bool UpdateData_IN() const;
// terminationstate_4:
//## statechart_method
inline bool terminationstate_4_IN() const;
// CalculateFiringData:
//## statechart_method
inline bool CalculateFiringData_IN() const;
// BookShell:
//## statechart_method
inline bool BookShell_IN() const;
//// Framework ////
protected :
//#[ ignore
enum TestSequenceBallisticCalcC_Enum {
OMNonState = 0,
UpdateData = 1,
terminationstate_4 = 2,
CalculateFiringData = 3,
BookShell = 4
};
int rootState_subState;
int rootState_active;
//#]
};
inline bool A::rootState_IN() const {
return true;
}
inline bool A::rootState_isCompleted() {
return ( IS_IN(terminationstate_4) );
}
inline bool A::UpdateData_IN() const {
return rootState_subState == UpdateData;
}
inline bool A::terminationstate_4_IN() const {
return rootState_subState == terminationstate_4;
}
inline bool A::CalculateFiringData_IN() const {
return rootState_subState == CalculateFiringData;
}
inline bool A::BookShell_IN() const {
return rootState_subState == BookShell;
}
#endif
and here is the cpp file.
//## auto_generated
#include <oxf/omthread.h>
//## auto_generated
#include "A.h"
//## operation handleInMessage(AFBaseMsgC *)
#include "AFBaseMsgC.h"
//## event evTestSuccess()
#include "TestBasePkg.h"
//## operation A(TestContextC *)
#include "TestContextC.h"
//## package TestSequencePkg
//## class A
A::A(TestContextC * context, IOxfActive* theActiveContext) : B(context) {
setActiveContext(theActiveContext, false);
initStatechart();
//#[ operation A(TestContextC *)
//#]
}
A::A(IOxfActive* theActiveContext) {
setActiveContext(theActiveContext, false);
initStatechart();
}
A::~A() {
//#[ operation ~A()
//#]
}
ACE_UINT32 A::handleInMessage(AFBaseMsgC * msg) {
//#[ operation handleInMessage(AFBaseMsgC *)
return getState();
//#]
}
void A::init() {
//#[ operation init()
startBehavior();
//#]
}
bool A::startBehavior() {
bool done = false;
done = OMReactive::startBehavior();
return done;
}
void A::initStatechart() {
rootState_subState = OMNonState;
rootState_active = OMNonState;
}
void A::rootState_entDef() {
{
rootState_subState = BookShell;
rootState_active = BookShell;
//#[ state ROOT.BookShell.(Entry)
registerProcedure(new F(this, this, this));
//#]
}
}
void A::rootState_exit() {
switch (rootState_subState) {
case UpdateData:
{
popNullTransition();
break;
}
default:
break;
}
rootState_subState = OMNonState;
}
IOxfReactive::TakeEventStatus A::rootState_processEvent() {
IOxfReactive::TakeEventStatus res = eventNotConsumed;
switch (rootState_active) {
case BookShell:
{
if(IS_EVENT_TYPE_OF(evTestSuccess_TestBasePkg_id))
{
rootState_subState = CalculateFiringData;
rootState_active = CalculateFiringData;
//#[ state ROOT.CalculateFiringData.(Entry)
registerProcedure(new G(this, this, this, this));
//#]
res = eventConsumed;
}
else if(IS_EVENT_TYPE_OF(evTestFailure_TestBasePkg_id))
{
//#[ transition 4
setState(ABORTED);
//#]
rootState_subState = terminationstate_4;
rootState_active = termi开发者_开发问答nationstate_4;
res = eventConsumed;
}
break;
}
case CalculateFiringData:
{
if(IS_EVENT_TYPE_OF(evTestSuccess_TestBasePkg_id))
{
pushNullTransition();
rootState_subState = UpdateData;
rootState_active = UpdateData;
res = eventConsumed;
}
else if(IS_EVENT_TYPE_OF(evTestFailure_TestBasePkg_id))
{
//#[ transition 3
setState(ABORTED);
//#]
rootState_subState = terminationstate_4;
rootState_active = terminationstate_4;
res = eventConsumed;
}
break;
}
case UpdateData:
{
if(IS_EVENT_TYPE_OF(OMNullEventId))
{
//## transition 5
if(true == isNextFmAvailable())
{
popNullTransition();
//#[ transition 5
populateNextFm();
//#]
rootState_subState = CalculateFiringData;
rootState_active = CalculateFiringData;
//#[ state ROOT.CalculateFiringData.(Entry)
registerProcedure(new G(this, this, this, this));
//#]
res = eventConsumed;
}
else
{
//## transition 6
if(false == isNextFmAvailable())
{
popNullTransition();
//#[ transition 6
setState(COMPLETED);
//#]
rootState_subState = terminationstate_4;
rootState_active = terminationstate_4;
res = eventConsumed;
}
}
}
break;
}
default:
break;
}
return res;
}
I know this wont compile straight off but maybe it can gice some hints as to why it becomes errors.
error: no matching function for call to `F::F(A* const, A* const, A* const) note: candidates are: F::F(TestContextC*, D*, IOxfActive*)
The problems in the code you posted are:
- You use
C
before you declare it. B::doSomething
is trying to call a privateC
constructor.B::doSomething
is not missing the return type and argument list.- You're missing semicolons to end the class.
But once you fix those and get this code:
class A { };
class C
{
public:
C(A* copy);
};
class B : public A {
void doSomething() {
C * c = new C(this);
}
};
it compiles cleanly.
With you code, I got the following errors.
:3: error: function definition does not declare parameters
:10: error: expected unqualified-id at end of input
You error must come from somewhere else in your code.
make sure the constructor of C is public, so that it can be accessed from B.
精彩评论