Click here to Skip to main content
15,923,051 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: bit shifting Pin
Waldermort25-Apr-06 19:51
Waldermort25-Apr-06 19:51 
GeneralRe: bit shifting Pin
Michael Dunn25-Apr-06 20:41
sitebuilderMichael Dunn25-Apr-06 20:41 
GeneralRe: bit shifting Pin
Waldermort25-Apr-06 20:43
Waldermort25-Apr-06 20:43 
AnswerRe: bit shifting Pin
Bob Flynn26-Apr-06 2:38
Bob Flynn26-Apr-06 2:38 
QuestionHTTP Server Pin
Harshabhi25-Apr-06 10:00
Harshabhi25-Apr-06 10:00 
QuestionDoes VC++ 2003 produce better code than VC++ 2005 ? Pin
Defenestration25-Apr-06 9:58
Defenestration25-Apr-06 9:58 
AnswerRe: Does VC++ 2003 produce better code than VC++ 2005 ? Pin
Steve Maier25-Apr-06 10:57
professionalSteve Maier25-Apr-06 10:57 
QuestionCartesian Inheritance Pin
etm12425-Apr-06 9:14
etm12425-Apr-06 9:14 
I have a class called Point. I am creating a class called Point3D that is inherited from Point. Point has private data members int xCoord, yCoord. Point also has functions called getX() and getY().

Point3D is inheriting from Point. Point 3D has a new datamember int zCoord. Point also has a function distanceFrom that looks like this:

double Point::distanceFrom(Point& p) { //distance between this point & p
return sqrt((xCoord - p.xCoord) * (xCoord - p.xCoord) +
(yCoord - p.yCoord) * (yCoord - p.yCoord));
}

Point's header file looks like this:
class Point{
public:
Point(); //default constructor
Point(double, double, string); //conversion constructor

double getX() const;
double getY() const;
string getName() const;
void setX(double);
void setY(double);
void setName(string);

double distanceFrom(Point&);
void printP();

private:
double xCoord, yCoord; //coordinates of the point
string name; //name of the point
};

so I am trying to overload the distanceFrom function to use the zCoord. Here is what I have:

double Point3D::distanceFrom(Point3D& p3D)
{
return sqrt((p3D.getX() - getX()) * (p3D.getX - getX()) +
(p3D.getY() - getY()) * (p3D.getY() - getY()) +
(p3D.zCoord - getZ()) * (p3D.zCoord - getZ()));
}

but i am getting these errors:
error C2475: 'Point::getX' : forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name
error C2475: 'Point::getX' : forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name
error C2296: '-' : illegal, left operand has type 'double (__thiscall Point::* )(void) const'

can anyone shed some light why i cannot do this? I just want to inherit the functions from Point (getX getY) to get x and y values. then get my z coordiate to get the distance.

Thank you,
Ed
AnswerRe: Cartesian Inheritance Pin
Ravi Bhavnani25-Apr-06 9:42
professionalRavi Bhavnani25-Apr-06 9:42 
GeneralRe: Cartesian Inheritance Pin
etm12425-Apr-06 9:46
etm12425-Apr-06 9:46 
GeneralRe: Cartesian Inheritance Pin
Ravi Bhavnani25-Apr-06 9:50
professionalRavi Bhavnani25-Apr-06 9:50 
GeneralRe: Cartesian Inheritance Pin
etm12425-Apr-06 9:54
etm12425-Apr-06 9:54 
GeneralRe: Cartesian Inheritance Pin
etm12425-Apr-06 9:58
etm12425-Apr-06 9:58 
AnswerRe: Cartesian Inheritance Pin
Ryan Binns25-Apr-06 16:07
Ryan Binns25-Apr-06 16:07 
QuestionOffice 12 new cool style look and feel Pin
Alex_Y25-Apr-06 9:13
Alex_Y25-Apr-06 9:13 
AnswerRe: Office 12 new cool style look and feel Pin
Joe Woodbury25-Apr-06 9:16
professionalJoe Woodbury25-Apr-06 9:16 
GeneralRe: Office 12 new cool style look and feel Pin
Alex_Y26-Apr-06 2:49
Alex_Y26-Apr-06 2:49 
AnswerRe: Office 12 new cool style look and feel Pin
Michael Dunn25-Apr-06 13:00
sitebuilderMichael Dunn25-Apr-06 13:00 
GeneralRe: Office 12 new cool style look and feel Pin
Alex_Y26-Apr-06 1:18
Alex_Y26-Apr-06 1:18 
QuestionHard question (maybe) Pin
#hackC++25-Apr-06 8:39
#hackC++25-Apr-06 8:39 
AnswerRe: Hard question (maybe) Pin
Kharfax25-Apr-06 8:42
Kharfax25-Apr-06 8:42 
AnswerRe: Hard question (maybe) Pin
Nick_Kisialiou25-Apr-06 8:43
Nick_Kisialiou25-Apr-06 8:43 
AnswerRe: Hard question (maybe) Pin
Maxwell Chen25-Apr-06 8:48
Maxwell Chen25-Apr-06 8:48 
GeneralRe: Hard question (maybe) Pin
Nick_Kisialiou25-Apr-06 8:50
Nick_Kisialiou25-Apr-06 8:50 
AnswerRe: Hard question (maybe) Pin
David Crow25-Apr-06 8:49
David Crow25-Apr-06 8:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.