So I have this header file:
#include <iostream>
#include <string>
class Furniture
{
float width, height, depth;
std::string name;
public:
// Constructor
Furniture(std::string name);
void ReadDimensions();
virtual void Print();
};
And this .cc file to define the functions declared above:
#include "Furniture.h"
Furniture::Furniture(std::string name)
{
this->name = name;
}
void Furniture::ReadDimensions()
{
// Read width
std::cout << "Enter width: ";
std::cin >> width;
// Read height
std::cout << "Enter height: ";
std::cin >> height;
// Read depth
std::cout << "Enter depth: ";
std::cin >> depth;
if (width <= 0 || height <= 0 || depth <=0)
std::cout << "You entered invalidd values\n";
}
And when I try to compile my main file which includes two child classes written in their own files, it gives me an error which reads
"Furniture.h:4: error: redefinition of ‘class Furniture’
Furniture.h:5: error: previous definition of ‘class Furniture’"
But as far as I know I declared the class correctly and didn't redeclare it in the definition. Why is it giving me this error and what can I do to fix it?