I am trying to create a class in one file that I will implement in the header of another file when I make an instance of that class.
My class file is
#include <iostream>
int main()
{
class Box
{
public:
int _width;
int _length;
int _height;
};
}
I saved this as boxclass.h, but I did not compile it. I read somewhere that when I add this to my header file, I should just save it as a text file.
My other file, which I tried to include my box class in, is this:
#include <iostream>
#include "/home/cole/cpp/boxclass.h"
using namespace std;
int main()
{
Box outer{3, 4, 5};
Box inner{1, 2, 3};
Box newB = outer-inner;
cout << newB << endl;
}
When I try to compile this, I get these errors repeated many times with many different values:
/home/cole/cpp/Boxclass.h:442:864: warning: null character(s) ignored
/home/cole/cpp/Boxclass.h:442:1: error: stray ‘\1’ in program
What’s going on?