Question

So from the title you get part of the idea. I'm working on writing a parser for a c++/discrete math class. My problem is that I'm having trouble getting xcode to recognize some of my objects.

So a parameter is a String an Id or an Expression, represented by the following object

    ParameterClass :: ParameterClass(Token UNO)
   {
    myToken = UNO;
   }
   ParameterClass :: ParameterClass(ExpressionClass DOS)
   {
    myExpression = DOS;
   }
   ParameterClass :: ParameterClass()
    {

   }
   ParameterClass :: ~ParameterClass()
  {


  }

an expression is represented by the following class

  ExpressionClass :: ExpressionClass(Token UNO, ParameterClass DOS, OperatorClass TRES,       ParameterClass CUATRO, Token CINCO)
  {
    myLEFT = UNO;
    paramUNO = DOS;
operatorUNO = TRES;
paramDOS = CUATRO;
myRIGHT = CINCO;

 }
  ExpressionClass :: ~ExpressionClass()
 {

And while it recognizes them in the header, ExpressionClass refuses to construct with Parameters DOS and CUATRO.

Any thoughts? I also notice that in these two classes the destructors are receiving the warning /error Exception specification in declaration does not match previous declaration.

Thanks in advance for the wisdom! -MJ

Was it helpful?

Solution

Moin,

It would have been nice, if you posted the class declarations. Since it seems as if both classes have instances of the other as members, I'm wondering whether this code would even compile. ParameterClass::myExpression etc. needed to be pointers, so you can forward-declare ExpressionClass in the header file and vice versa. Then you have change the parameter types accordingly.

Maybe something like:

// parameterclass.h

class ExpressionClass;                     // foward-declaration
class Parameterclass
{
    ExpressionClass* myExpression;
    ParameterClass(ExpressionClass* DOS);  // por favor, utiliza nombres significativos
    ...
}

Greez Albjeno

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top