I am currently working on a lab and I have been trouble shooting a class type redefinition error with no luck.
1 2 3 4 5 6 7 8 9
1>c:\users\...\desktop\lab11\lab11\vans.h(13): error C2011: 'Vans' : 'class' type redefinition
1>c:\users\...\desktop\lab11\lab11\auto.h(29) : see declaration of 'Vans'
1>c:\users\...\desktop\lab11\lab11\vans.cpp(12): error C2027: use of undefined type 'Vans'
1>c:\users\...\desktop\lab11\lab11\auto.h(29) : see declaration of 'Vans'
1>c:\users\...\desktop\lab11\lab11\vans.cpp(12): error C2062: type 'void' unexpected
1>c:\users\...\desktop\lab11\lab11\vans.cpp(13): error C2143: syntax error : missing ';' before '{'
1>c:\users\...\desktop\lab11\lab11\vans.cpp(13): error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\...\desktop\lab11\lab11\vans.cpp(22): error C2027: use of undefined type 'Vans'
...
This is followed by about forty or so more errors all along the same lines of things are not declared. I assume the key is the "Class type redefinition" part.
Currently I have a program with seven files looking something like this
Auto.h
1 2 3 4 5 6 7 8 9
#ifndef AUTO_H
#define AUTO_H
class Auto
{
public:
...
};
#endif
Auto.cpp
1 2 3 4
#include "Auto.h"
#include<cstring>
...
//A bunch of functions
vans.h
1 2 3 4 5 6 7 8 9 10 11 12
#ifndef VANS_H
#define VANS_H
#include<cstring>
#include "Auto.h"
class Vans: public Auto
{
public:
...
};
#endif
#include<iostream>
#include "suvs.h"
#include "vans.h"
int main()
{
...
}
From what I have been reading the problem comes from having your header file be called more than once and that having the Include guards on the header files would fix it. So what I am asking, are my guards syntax wrong or are my #includes way out of line?
Using Microsoft Visual Studio and I can give the full files if needed.