[SOLVED] NewPing '((Range*)this)->Range::bottomRF' does not have class type

What does this error mean?
Im trying to get the range from the sensor. Where am I doing wrong?

.h

//
//  Range.h
//  Handles range to ground and altitude
//
//  Created by on 2013-03-27.
//
//

#ifndef RANGE_H_
#define RANGE_H_

#include <NewPing.h>


#define BOTTOM_RF_PIN       5
#define BOTTOM_RF_ECHO_PIN  10
#define BOTTOM_RF_MAX       200


class Range {
public:
	Range();
	void init();
    float toGround();
    float toCeiling();
    float altitude();
    NewPing bottomRF(int s1= BOTTOM_RF_PIN, int s2=BOTTOM_RF_ECHO_PIN , int s3=BOTTOM_RF_MAX);
private:
    
    
};

#endif /* RANGE_H_ */

.cpp

//
//  Range.cpp
//  Handles range to ground and altitude
//
//  Created by on 2013-03-27.
//
//



#include "Range.h"



Range::Range(){}

void Range::init()
{
    //Check if distance to ground is available
    if (bottomRF.ping_cm()) 
        Serial.println("RF Bottom: [OK]");
    else
        Serial.println("RF Bottom: [FAIL]");
    
    
}

//Dinstance to ceiling in cm
float Range::toCeiling()
{
    return bottomRF.ping_cm();
}



//Dinstance to ground in cm
float Range::toGround()
{
    return bottomRF.ping_cm();
}



//Altitude to earth in m
float Range::altitude()
{
    return 1.0;
}
Users/user/Dropbox/Projects/Arduino/libraries/Range/Range.cpp: In member function 'void Range::init()':
/Users/user/Dropbox/Projects/Arduino/libraries/Range/Range.cpp:20: error: '((Range*)this)->Range::bottomRF' does not have class type
/Users/user/Dropbox/Projects/Arduino/libraries/Range/Range.cpp: In member function 'float Range::toCeiling()':
/Users/user/Dropbox/Projects/Arduino/libraries/Range/Range.cpp:31: error: '((Range*)this)->Range::bottomRF' does not have class type
/Users/user/Dropbox/Projects/Arduino/libraries/Range/Range.cpp: In member function 'float Range::toGround()':
/Users/user/Dropbox/Projects/Arduino/libraries/Range/Range.cpp:39: error: '((Range*)this)->Range::bottomRF' does not have class type

What exactly are you trying to do ?

The 2 programs that you posted are for a library apparently called Range

Please post your program that uses the library because without it and an explanation of what you are doing it is impossible to help.

What is the compiler trying to tell you?

A very simple method is to copy the error message and pass it too your favorite web search engine. There is always somebody who has already had the same problem. Below is one which asks basically the same question:

The problem is the return value and how C++ uses constructors.

Cheers!

Problem solved. :slight_smile:

//
//  Range.h
//  Handles range to ground and altitude
//
//  Created by Alex Anis on 2013-03-27.
//
//

#ifndef RANGE_H_
#define RANGE_H_

#include <NewPing.h>


#define BOTTOM_RF_PIN       5
#define BOTTOM_RF_ECHO_PIN  10
#define BOTTOM_RF_MAX       200


class Range {

    
public:
	Range():bottomRF(BOTTOM_RF_PIN, BOTTOM_RF_ECHO_PIN , BOTTOM_RF_MAX){};
	void init();
    float toGround();
    float toCeiling();
    float altitude();
    NewPing bottomRF;

    
};

#endif /* RANGE_H_ */