is gcc a c++ compiler
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > is gcc a c++ compiler




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    is gcc a c++ compiler  
Tommy


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

Hi call,

"man gcc" stated that gcc is a c++ compiler.  However, I have the following
*VERY SIMPLE* code in c++ that doesn't compile in gcc.  It compiles fine in
VC++ 7.0.  I have no clue why.  TIA

Error message:
gcc test.cc
/tmp/ccMJrkgw.o(.text+0x18): In function `main':
: undefined reference to `Point::Point[in-charge]()'
/tmp/ccMJrkgw.o(.text+0x3f): In function `main':
: undefined reference to `Point::Point[in-charge](double, double)'
/tmp/ccMJrkgw.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status



test.cc:
#include "Point.h"
#include <stdio.h>

int main()
{
Point a;
Point b(3, 4);
//printf("Distance is %f", a.getDistance(b));
return 0;
}

Point.h:
#ifndef Point_H
#define Point_H

class Point
{
private:
double m_x, m_y;

public:
Point();
Point(double x, double y);
double getDistance(Point p);
void setPoint(double x, double y);
double getX();
double getY();

};

#endif


Point.cc:
#include "Point.h"
#include <math.h>

Point::Point()
{
setPoint(0, 0);
}

Point::Point(double x, double y)
{
setPoint(x, y);
}

void Point::setPoint(double x, double y)
{
m_x = x;
m_y = y;
}
double Point::getX()
{
return m_x;
}
double Point::getY()
{
return m_y;
}

double Point::getDistance(Point p)
{
return pow(pow(p.getX() - m_x, 2) + pow(p.getY() - m_y, 2), 0.5);
}






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:17 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register