class A { }
class B : public A {
doSomething {
C * c = new C(this);
}
}
class C
{
C(A* copy);
}
在下面的例子中,我得到以下錯誤:從繼承的類調用這個指針的方法變成常量
error: no matching function for call to `C::C(B* const)'
我wan't獲得的指針在這個電話,但對於某種原因我無法解決這個問題。可能是一些愚蠢的錯字,但它的Rhapsody生成,我真的不覺得我能控制爲什麼編譯時遇到這個問題。
試圖添加另一個頭文件。它不會編譯,因爲它需要包含的文件太多了,但這是執行的實際代碼(已更改的類名),並且基礎類正在工作。
#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
這裏是cpp文件。
//## 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 = terminationstate_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;
}
我知道這不會編譯直客,但也許它可以GICE一些線索,爲什麼它變成錯誤。
error: no matching function for call to `F::F(A* const, A* const, A* const) note: candidates are: F::F(TestContextC*, D*, IOxfActive*)
這不是真正的代碼不是嗎?在提問時複製粘貼來自編輯器的代碼總是更好。如果您無法提供真實的代碼,請製作一個測試程序,您可以使用該程序重現問題並從該處發佈代碼。 – Naveen 2010-03-01 08:05:45
您的代碼無效。請發佈有錯誤的原始代碼。 – 2010-03-01 08:06:18
請發佈您正在編譯的實際代碼。 – 2010-03-01 08:07:29