0

I got a issue when I cout a function. The next code is where the IDE gives me the error:

cout << "La cuerda de raiz tiene valor de: "<< chord.rootChord(const clsSpanCalculation&)
     << "La cuerda de punta tiene valor de: " << chord.tipChord(clsSpanCalculation &sC);

The classes clsSpanCalculation and clsChordParameters are defined in main as span and chord respectively.

I am using a header, the classes are developed there. The headers are these ones:

#ifndef __IASS_Project__wingSizing__
#define __IASS_Project__wingSizing__

#include <stdio.h>
#include <cmath>

class clsSpanCalculation{
    float wingArea, aspectRatio;
public:
    clsSpanCalculation(){}
    float get_wingArea(void)const{return wingArea;}
    void set_wingArea(float Sw){wingArea = Sw;}
    float get_aspectRatio(void)const{return aspectRatio;}
    void set_aspectRatio(float AR){aspectRatio = AR;}

    float span()const{
        float span;
        span = sqrt(aspectRatio*wingArea);
        return span;
    }
};

class clsChordParameters{
    float percentRectArea, percertTrapArea, taperRatio;
public:
    float get_percentRectArea(void)const{return percentRectArea;}
    void set_percentRectArea(float Srect){percentRectArea = Srect;}
    float get_percentTrapArea(void)const{return percertTrapArea;}
    void set_percentTrapArea(float Strap){percertTrapArea = Strap;}
    float get_taperRatio(void)const{return taperRatio;}
    void set_taperRatio(float lambda){taperRatio = lambda;}

    float rootChord (const clsSpanCalculation &clsSpanCalculation){
        float rootChord, lambdaplus;
        lambdaplus= taperRatio + 1;
        rootChord = (2*(clsSpanCalculation.get_wingArea()*(percentRectArea*(lambdaplus)+(2*percertTrapArea))))/((clsSpanCalculation.span()*lambdaplus)/2);
        return rootChord;
    }

    float tipChord (const clsSpanCalculation &sC){
        float rootChord, tipChord, lambdaplus;
        lambdaplus= taperRatio + 1;
        rootChord = (2*(sC.get_wingArea()*(percentRectArea*(lambdaplus)+(2*percertTrapArea))))/((sC.span()*lambdaplus)/2);
        tipChord = rootChord*taperRatio;
        return tipChord;
    }
};

#endif /* defined(__IASS_Project__wingSizing__) */

The error that the IDE gives me is this one: expected primary-expression before "const"

  • Perhaps the line number would be useful to know – Ed Heal Jul 03 '15 at 17:50
  • 1
    Don't use `const` or `static` for passing parameters to functions. You only need to pass the variable name. Otherwise the compiler may think you are declaring a function. – Thomas Matthews Jul 03 '15 at 17:51
  • The compiler is expecting an expression. Perhaps you meant to use `chord.rootChord(someObject)` and not `chord.rootChord(const clsSpanCalculation&)`. – R Sahu Jul 03 '15 at 17:53

1 Answers1

0

this code looks wrong

 cout << "La cuerda de raiz tiene valor de: "<< chord.rootChord(const clsSpanCalculation&)
 << "La cuerda de punta tiene valor de: " << chord.tipChord(clsSpanCalculation &sC);

your rootchord() and tipchord() function expects a clsSpanCalculation object insead you are passing it

     const clsSpanCalculation&  // error no object is declared
     const clsSpanCalculation& sC //error you are passing the address of C but the tipchord() expects the object C not its address

What you want to do is make an object of these classes and pass then

  cout << "La cuerda de raiz tiene valor de: "<< chord.rootChord(clsSpanCalculation C)// you still have to initialise C an sC
  cout<< "La cuerda de punta tiene valor de: " << chord.tipChord(clsSpanCalculation sC);
rahul tyagi
  • 613
  • 1
  • 6
  • 20