-
Header file
I have cooked up a header file(i got it from the tutorial and made it into a header file) but when i compile it i get tjeis strange error, here is the code:
Code:
#ifndef _ANIMAL_
#define _ANIMAL_
namespace Mammal
{
class Animal
{
public:
void eat();
void sleep();
void drink();
private:
int legs;
int arms;
int age;
};
}
#endif
-
oh, i forgot, here is the error:
Code:
g++.exe: no input files
make.exe: *** ["Animal] Error 1
Execution terminated
-
right, i'm starting to think it's because i have no source files, any ideas?
-
It needs a constructor. I don't know if that's the problem, but try it anyway.
-
-
You don't compile header files. If you just want to test that the syntax is good, create a source file that includes the header, then compile that. Even better would be to create a simple main that tests the class and that you expand as you add to the class.
-
i tried putting a constructor and a deconstructor, do i need a deconstructor?
-
-
You don't need a constructor or destructor in a class, although you almost always want a constructor. That has nothing to do with the error, though.
-
Funny thing, i made the exact same error a couple of weeks ago and asked this very same board, scroll back a couple of pages and you can probably find the thread.
Don't start your header name with "_" like you did, i bet you, it will fix the problem :)
-
>> i bet you, it will fix the problem
While technically it is against the rules of the language standard, in practice this almost never causes a problem. It almost certainly was not the source of the problem here.