[SLUG] OT - need help with C++ compile

From: George Curran (gcurran@gte.net)
Date: Mon Nov 12 2001 - 18:49:25 EST


Hello Sluggers

I am trying to learn C++ by working through the Sams "Teach Yourself C++
Programming in 21 Days". I have a SuSE 7.1 system using the gcc complier
version 2.95.2 19991024 (release) . The problem I have is when I try to
use an include file (other than iostream.h) and I get the following error
on compile:
viffer@linux:~/cpp.21days > g++ lst6.7.cpp -o example
lst6.7.cpp:4: /home/viffer/cpp.21days/cat.hpp : No such file or directory

Here is the include file and the main program that calls the include file.

cat.hpp:
++++++++++++++++++++++++++++++++++++++
#include <iostream.h)
class cat
{
        public:
                cat(int initialage);
                ~cat();
                int getage() { return itsage; }
                void setage ( int age) { itsage = age; }
                void meow() { cout << "Meow.\n"; }
        private:
                int itsage;
};
+++++++++++++++++++++++++++++++++++++++++++++++++

lst6.7.cpp:
+++++++++++++++++++++++++++++++++++++++++++++++++
// demonstrates inline functions
// and inclusion of header files

#include " /home/viffer/cpp.21days/cat.hpp "

cat::cat(int initialage) // constructor of cat
{
        itsage = initialage;
}

cat::~cat() // destructor of cat - no action
{
}

// create a cat, set its age, have it
// meow, tell us its age, then meow again
void main()
{
        cat Frisky(5);
        Frisky.setage(5);
        Frisky.meow();
        cout << "Frisky is a cat who is ";
        cout << Frisky.getage() << " years old.\n";
        Frisky.meow();
        Frisky.setage(7);
        cout << "Now Frisky is ";
        cout << Frisky.getage() << " years old.\n";
}
++++++++++++++++++++++++++++++++++++++++++++++

I would appreciate if anyone can tell me what I am doing wrong.

Thanks

-- 
George Curran

[email] gcurran@gte.net http://home1.gte.net/gcurran/index.htm



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 17:49:37 EDT