Unexpected Class Error
Jun 8, 2015 at 9:57pm UTC
Hello, I have this header and it generates a strange error :
obiect.h(10): error C2236: unexpected 'class' 'Obiect'. Did you forget a ';'? I'm using microsoft visual 2010 if that matters. Thanks in advance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#ifndef OBIECT_H
#define OBIECT_H
#include"Material.h"
class Obiect
{ public :
Obiect (Material & mat); // constructor
~Obiect(); // destructor
Obiect (const Obiect& obj); // copy constructor
Material f_mat() const ;
protected :
Material * m_mat;
}; //skipped the rest, mostly derived classes
Here's the implementation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#include "Obiect.h"
#include "Material.h"
extern double g=9.81;
Obiect::Obiect( Material & mat)
{
m_mat=new Material(mat);
};
Obiect::~Obiect()
{
delete m_mat;
};
Material Obiect::f_mat() const
{
return *m_mat;
};
Obiect::Obiect(const Obiect & obj)
{
m_mat=new Material;
m_mat=&obj.f_mat();
};// skipped the derived classes declarations
Last edited on Jun 8, 2015 at 9:57pm UTC
Jun 8, 2015 at 10:38pm UTC
If that is the beginning of the file, the problem probably resides in "Material.h"
Jun 9, 2015 at 1:04pm UTC
Thanks, it looks like I forgot to write a semicolon inside the Material.h after a class declaration.
Topic archived. No new replies allowed.