3 Replies - 564 Views - Last Post: 12 January 2012 - 09:26 AM Rate Topic: -----

#1 Douggler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 16-August 11

error: 'CEditor' does not name a type

Posted 11 January 2012 - 09:15 AM

Hi All

I've been following game-making tutorials on SdlTutorials.com and I'm now trying to make a simple editor to edit maps, entities, etc.

The CEditor class is a descendent of the CEntity class which has no problems on its own. When I try to declare a simple static object of CEditor, EditorControl, the compiler tells me that "'CEditor' does not name a type", even though I've included the correct header file and header guards in an apparently correct way.

CEditor.h
#ifndef CEDITOR_H
#define CEDITOR_H

#include "CEntity.h"

class CEditor: public CEntity
{
    public:
        static CEditor EditorControl;
        
    public:
        CEditor();
};

#endif



CEditor.cpp

#include "CEditor.h"

CEditor CEditor::EditorControl;

CEditor::CEditor()
{
    CEntity::CEntity();

    Type = ENTITY_TYPE_GENERIC;
    Flags = ENTITY_FLAG_NONE;
}



Can anyone spot any silly mistakes I'm making?

Is This A Good Question/Topic? 0
  • +

Replies To: error: 'CEditor' does not name a type

#2 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1833
  • View blog
  • Posts: 4,927
  • Joined: 27-December 05

Re: error: 'CEditor' does not name a type

Posted 11 January 2012 - 10:21 AM

This wouldn't cause your error, but there's no reason to be calling the base class default constructor (on line 7 of CEditor.cpp) since that will be done implicitly by the derived class constructor.

Is that the only error message? Can you instantiate a CEntity?
Was This Post Helpful? 1
  • +
  • -

#3 Douggler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 16-August 11

Re: error: 'CEditor' does not name a type

Posted 12 January 2012 - 09:20 AM

Yes, the CEntity class works fine. Thanks, I was not sure before about the constructor so I've been doing this to 'make sure'. I guess I would only have to do this if it was virtual.

My code suddenly wants to compile now and I have no idea how it worked this time. I literally just opened the project and hit 'compile and run' and it worked! It must have been some weird bug on my computer. :clap:
Was This Post Helpful? 0
  • +
  • -

#4 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1833
  • View blog
  • Posts: 4,927
  • Joined: 27-December 05

Re: error: 'CEditor' does not name a type

Posted 12 January 2012 - 09:26 AM

View PostDouggler, on 12 January 2012 - 11:20 AM, said:

My code suddenly wants to compile now and I have no idea how it worked this time. I literally just opened the project and hit 'compile and run' and it worked! It must have been some weird bug on my computer. :clap:

Or maybe you forgot to save & rebuild after the last correction that you made last night. :whistling:

Glad you got it working.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1