在编译我已更改的大型程序部分时收到此错误,但它出现在我没有更改的部分。我在unix上使用gcc。我在网上看过有关类似错误的讨论,但那些涉及模板,我没有使用。构造函数也应该出现在类之前,而不是它之前。这是给出错误的部分:
#ifndef __GRIDG_H
#define __GRIDG_H
#include "part1g.h"
//=================== GridParams Class
// class for specifying the computational grid
class GridParams :public ParameterGroup
{IntParameter J;
IntParameter K;
ScalarParameter x1s;
ScalarParameter x1f;
ScalarParameter n1;
ScalarParameter x2s;
ScalarParameter x2f;
ScalarParameter n2;
StringParameter dx1;
StringParameter dx2;
IntParameter PeriodicFlagX1;
IntParameter PeriodicFlagX2;
IntParameter Geometry; // which geometry, RZ, XY, or even R-Theta
// storage used by GUI
protected:
Vector2** X;
public:
GridParams();
~GridParams();
int getJ() {return J.getValue();}
int getK() {return K.getValue();}
int getPeriodicFlagX1() {return PeriodicFlagX1.getValue();}
int getPeriodicFlagX2() {return PeriodicFlagX2.getValue();}
Scalar getX1s() {return x1s.getValue();}
Scalar getX1f() {return x1f.getValue();}
Scalar getX2s() {return x2s.getValue();}
Scalar getX2f() {return x2f.getValue();}
Scalar mapping_function(Scalar x, Scalar x1, Scalar x2, Scalar n);
Grid* CreateCounterPart();
#ifdef MPI_VERSION
Grid* CreateCounterPart(const ostring &MPIpartition);
#endif /*MPI_VERSION */
public:
/**
* Due to problems with conversion from double to float and back to double
* in the process of initializing the cell vertices when OOPIC is run in
* parallel, I'm changing the signature of the
* Vector2** createCellVertices(); member function to make sure that the
* same deltaX is used in each region. The new signature has the beginning
* of the region's x1 coordinates and the deltaX1. The latter
* will be calculated in the same way on all processes. All arguments
* become of type Scalar as well for consistent handling of the float
* and double types.
* dad, Fri May 3 2002.
*/
/*
* Removed all hard-coded floats from the code, so conversion from
* double to float to double should no longer happen. RT, 2003/12/09
*/
Vector2** createCellVertices(Scalar x1min, Scalar deltaX1);
Vector2** getCellVertices();
void deleteCellVertices();
};
#endif // __GRIDG_H
这是part1g.h
//part1.h
#ifndef __PART1G_H
#define __PART1G_H
#include "param.h"
class Evaluator;
//=================== ParameterGroup Class
// Abstract base class for conceptual groups of parameters
class ParameterGroup :public BaseParameter
{protected:
oopicList<BaseParameter> parameterList;
oopicList<RuleBase> RuleList;
oopicList<ParameterGroup> parameterGroupList;
// list of rules constraining parameters in the group
public:
ostring name; // name of group
ostring errorMessages;
// contains errors in input (not an integer or not a scalar)
BOOL legal;
oopicList<ostring> ruleMessages;
int LegalParamName(ostring pname) {
// search the parameterList for this name
int ans=0;
oopicListIter<BaseParameter> plistI(parameterList);
for(plistI.restart();!plistI.Done();plistI++)
ans|=plistI.current()->getName() == pname;
return ans;
}
ParameterGroup * LookupGroupByName(ostring pname);
// contains messages due to rule firings
public:
ParameterGroup() : BaseParameter() {};
virtual ~ParameterGroup() {};
virtual void setValues(oopicList<ostring> &ostringList);
// Set the values of the parameters in the group from a list
// of ostrings of the form ostring("name value")
oopicList<BaseParameter>* getParameterList();
// Return list of parameters in group
BaseParameter* getParameter(ostring name);
// Return a sub-parameter by name
ostring GetName() {return name;};
void setName(ostring _name) {name = _name;};
void addLimitRule(ostring _name, ostring _op,
double _val, ostring _reason, int
_intrinsic);
ostring addRule(std::ifstream &fin);
// Add a Rule to known rules via a stream
void addRelationRule(ostring _name1, ostring _op, ostring _name2,
ostring _reason, int _intrinsic);
void addAlgebraRule(ostring _name1, ostring _op1, ostring _name2,
ostring _op2, double _val, ostring _reason, int _intrinsic);
virtual void checkRules();
// Fire all applicable rules and accumulate results into Messages.
void showRules();
// Diagnostic -- show all rules known by group
void showRuleMessages();
// Diagnostic -- show results of all rule violations
void showValues();
// Diagnostic -- show names and values of all parameters in group
void describe();
virtual void writeOutputFile(std::ofstream &fout);
// writes to file
virtual ostring InitializeFromStream(std::ifstream &fin);
// initializes parametergroup from stream
ostring getName();
virtual oopicList<ostring>* getErrorMessages()
{ return ruleMessages.isEmpty()
?(oopicList<ostring>* NULL:&ruleMessages; }
virtual ostring getDescription()
{ return getName(); };
private:
ostring parseStringList(oopicList<ostring> &ostringList);
// Support function for setValues
ostring parseName(ostring str);
// Support function for parseStringList
ostring parseValue(ostring str);
// Support function for parseStringList
};
#endif // __PART1G_H
答案 0 :(得分:4)
当编译器说某个语法元素(在这种情况下是class
关键字)之前有错误时,请查看之前的内容。我打赌你在}
结束时遗漏了;
或part1g.h
。
编辑:查看part1g.h
,一些小问题:
ParameterGroup() : BaseParameter() {}
virtual ~ParameterGroup() {}
ostring GetName() {return name;}
void setName(ostring _name) {name = _name;}
virtual ostring getDescription()
{ return getName(); }