I'm working on a little program and I want to break it up into multiple source files and also use a make file. I can't seem to get my program to compile though and I don't know why. I type
and it doesn't compile. Here are some source files that illustrate my problem.Code:mingw32-make -f makefile.mak
Code:// main.cpp #include <iostream> using namespace std; int main () { CPoint A, B; A.set_point (3,4); B.set_point (5,-2); cout << "distance between points: " << distance(A, B) << endl; return 0; }Code:// CPoint.cpp #include <cmath> class CPoint { double x, y; public: void set_point (double,double); double distance(CPoint,CPoint); }; void CPoint::set_point (double a, double b) { x = a; y = b; } double CPoint::distance (CPoint A, CPoint B){ double dist; dist = sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y)); return dist; }Code:#makefile.mak all: Mult Mult: main.o CPoint.o g++ main.o CPoint.o -o Mult main.o: main.cpp g++ -c main.cpp CPoint.o: CPoint.cpp g++ -c CPoint.cpp clean: rm -rf *o Mult



LinkBack URL
About LinkBacks



CornedBee