C++ classes questions?
I took c++ a long time ago in school, now I am trying to relearn everything again. I think this is a very stupid question but I don't care, here it goes:
Code:
//test.cpp Code:
//point.h Code:
//point.cpp Ok so that is my code, as you can see three (3) files. When I try to compile this is what happenes: bash-3.00$ g++ test.cpp In file included from point.h:3, from test.cpp:1: point.cpp:3: error: syntax error before `::' token point.cpp:9: error: syntax error before `::' token bash-3.00$ What am I doing wrong here. I have tried to do it many different ways, but nothing seems to work. Please, help!! |
point.hh shouldn't include point.cc, but point.cc should include point.hh; to compile:
$ g++ test.cc point.cc (use your favorite extensions instead of hh and cc if you care -- but emacs gets c++-headers right for .hh but not .h; just a hint) Hope this helps, Jonas |
Hey,
that is not working. If I #include point.h in point.cpp i get different compile errors. To make sure, I got some code, straight our of the book and typed it in. After compiling I got the same kind of errors. The code involves a time.cpp, time.h, and a time_test.cpp. when I compile this is what happens: Code:
lab35->gcc time_test.cpp |
Use g++ instead of gcc or at an -lstdc++ ot your compile command.
|
Okay... I made a few changes...
point.hh Code:
#ifndef POINT_HH point.cc Code:
#include <iostream> |
All times are GMT -5. The time now is 10:51 PM. |