作者tyc5116 (累人啊....)
看板C_and_CPP
标题[语法] 关於List的问题
时间Mon Mar 16 18:14:40 2009
如题,我将其类别撰写如下
//Arc.h
#ifndef ARC_H
#define ARC_H
#include <string>
using namespace System::Drawing;
using namespace System::Drawing::Drawing2D;
using namespace std;
class ArcLine{
public:
ArcLine();
~ArcLine();
};
#endif
//Arc.cpp
#include "stdafx.h"
#include "Arc.h"
using namespace System::Drawing;
ArcLine::ArcLine(){}
//A_List.h
#ifndef A_LIST_H
#define A_LIST_H
#include "Arc.h"
class Truckload_Arc{
public:
Truckload_Arc();
void Add_Arc(ArcLine* pArc);
private:
class A_List{
public:
A_List(ArcLine* pNew_Arc):pArc(pNew_Arc),
pNext(0){}
ArcLine* pArc;
A_List* pNext;
};
A_List* pHead;
A_List* pTail;
A_List* pCurrent;
};
//A_List.cpp
#include "stdafx.h"
#include "Arc.h"
#include "A_List.h"
Truckload_Arc::Truckload_Arc(){pHead=pTail=pCurrent=0;}
void Truckload_Arc::Add_Arc(ArcLine* pArc){
A_List* pA_List= new A_List(pArc);
if (pHead)
pTail->pNext=pA_List;
else
pHead=pA_List;
pTail=pA_List;
}
但是在主程式呼叫时如下
Truckload_Arc Arc_Truckload;
Arc_Truckload.Add_Arc(new ArcLine(ID,Position,Position));
上面这行则会出错,错误讯息如下
error C2061: 语法错误 : 识别项 'ArcLine'
error C2660: Truckload_Arc::Add_Arc' : 函式不使用 3 引数
error C2143: 语法错误 : 遗漏 ';' (在 ')' 之前)
error C2143: 语法错误 : 遗漏 ';' (在 ')' 之前)
因为我有其它的类别,其型式皆与这个类似,所以都copy的
但奇怪的是其它的都可以,只有这个Arc会出错,仔细对过後应该和其它格式相同
请问这该怎麽解决呢,谢谢,为了版面,简化了很多东西,如须要再补的话
再请推文一下,谢谢
※ 编辑: tyc5116 来自: 163.18.48.28 (03/16 18:15)
1F:推 plover:ArcLine 没有吃三个引数的 ctor 03/16 19:11
2F:→ plover:而且 memory leak的情形好像很多喔 @@a 03/16 19:12
3F:→ tyc5116:不太懂.... 03/16 19:48