Reputation: 495
To my understanding, header guards are used to avoid accidentally including something multiple times. However, when I include a class multiple times I still get a redefinition error. Shouldn't the header guards take care of this? //animal.h
#ifndef ANIMAL_H
#define AMIMAL_H
class Animal {};
#endif
//main.cpp
#include"animal.h"
#include"animal.h"
Error C2011: 'Animal' : 'class' type redefinition
Upvotes: 1
Views: 1053
Reputation: 81936
#ifndef ANIMAL_H
#define AMIMAL_H
^
Those aren't both ANIMAL_H
.
Upvotes: 6