Working with classes and the error " undeclared identifier"

 

Hey! First of all thanks for taking some time out of your day to read my question. 

So I am playing around with classes and I keep on stumbling across the same problem:

When I define lets say tpLong in this class: 

public:
                     CNbpExpert(void);
                    ~CNbpExpert(void);
   bool              Init(void);

protected:  
   bool              LongOpened(void);
---------------
bool CNbpExpert::Init(void)
  {
//---    Take Profit for long
   double   tpLong      =     TakeProfitOpenL;
 }

And try to use this identifier in another class: 

bool CNbpExpert::LongOpened(void)
{
   //---    Opening position long 
   CTrade            m_trade;                      // trading object
   bool res = false; 
   if(BreakoutL == true)
     {
         while(OpenOrders<=6)
           {
               //---    Buying at the specified symbol with specified SL and TP
               double volume= 0.156;                                           // specify a trade operation volume
               string symbol= _Symbol;                                        //specify the symbol, for which the operation is performed
               int    digits= (int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);   // number of decimal places
               double point=  SymbolInfoDouble(symbol,SYMBOL_POINT);          // point
               double bid=    SymbolInfoDouble(symbol,SYMBOL_BID);            // current price for closing LONG
               double SL=     slLong;                                         // unnormalized SL value
               SL=NormalizeDouble(SL,digits);                                 // normalizing Stop Loss
               double TP=     tpLong;                                         // unnormalized TP value
               TP=NormalizeDouble(TP,digits);                                 // normalizing Take Profit

It keeps giving me the error "tpLong undeclared identifier"

Thanks again for taking the time, 

Have a great rest of your day. 

 
Foenkelito:

Hey! First of all thanks for taking some time out of your day to read my question. 

So I am playing around with classes and I keep on stumbling across the same problem:

When I define lets say tpLong in this class: 

And try to use this identifier in another class: 

It keeps giving me the error "tpLong undeclared identifier"

Thanks again for taking the time, 

Have a great rest of your day. 

Add the tpLong in the members of the class 

public:
  double         tpLong;
                     CNbpExpert(void);
                    ~CNbpExpert(void);
   bool              Init(void);

protected:  
   bool              LongOpened(void);
---------------
bool CNbpExpert::Init(void)
  {
//---    Take Profit for long
    tpLong      =     TakeProfitOpenL;
 }
 
Lorentzos Roussos #:

Add the tpLong in the members of the class 

Thanks incredibly much! This also fixed a lot of different errors I had. 

:)