Thread: member functions can't see private data members

  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179

    member functions can't see private data members

    Hi all,

    I know this is something obvious, but I need another pair of eyes to look at it and tell me what I'm doing. I have some class methods declared like this:
    Code:
    #include "aspect.h" //defines Aspect
    #include <map>
    #include <string>
    
    namespace sge {
        typdef std::map<std::string, Aspect*> StringAspectMap;
    
        class Object  {
        private:
            StringAspectMap aspectDict;
        public:
            void initAspects();
            void updateAspects(float dtime);
            void destroyAspects();
        };
    }
    Then over in my cpp I'm implementing them like this:
    Code:
    #include "object.h"
    using namespace sge;
    
    void Object::initAspects() {
        for (StringAspectMap::iterator itr = aspectDict.begin(); itr != apsectDict.end(); ++itr)
            itr->second->init();
    }
    
    void Object::updateAspects(float dtime) {
        for (StringAspectMap::iterator itr = aspectDict.begin(); itr != apsectDict.end(); ++itr)
            itr->second->update(dtime);
    }
    
    void Object::destroyAspects() {
        for (StringAspectMap::iterator itr = aspectDict.begin(); itr != apsectDict.end(); ++itr)
            itr->second->destroy();
    }
    Now when I compile this, I get:
    ../code/src/object.cpp: In member function ‘void sge::Object::initAspects()’:
    ../code/src/object.cpp:183: error: ‘apsectDict’ was not declared in this scope
    ../code/src/object.cpp: In member function ‘void sge::Object::updateAspects(float)’:
    ../code/src/object.cpp:188: error: ‘apsectDict’ was not declared in this scope
    ../code/src/object.cpp: In member function ‘void sge::Object::destroyAspects()’:
    ../code/src/object.cpp:193: error: ‘apsectDict’ was not declared in this scope
    This doesn't make any sense to me. I'm in the right namespace, in the right class, implementing functions that I know I prototyped, but they can't see my private data. Can anyone see what I'm doing wrong?
    Illusion and reality become impartiality and confidence.

  2. #2
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179
    I'm so stupid. aspect, not apsect. And I've been seriously sitting here for an hour trying to figure out what I'm doing wrong. Once again proving that the best help is to write a question about your problem.
    Illusion and reality become impartiality and confidence.

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    It's also the power of copy-paste. It would have been much easier to catch if it only appeared in one function... It's a hate-love relationship the one I have with copy-paste.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. webBrowser problem
    By algi in forum C# Programming
    Replies: 7
    Last Post: 08-19-2005, 09:35 AM
  2. Not able to access private data members
    By smitsky in forum C++ Programming
    Replies: 31
    Last Post: 05-09-2004, 07:06 PM
  3. Menu Item Caption - /a for right aligned Accelerator?
    By JasonD in forum Windows Programming
    Replies: 6
    Last Post: 06-25-2003, 11:14 AM
  4. Accessing private data members
    By maloy in forum C++ Programming
    Replies: 11
    Last Post: 10-04-2002, 02:48 PM
  5. How do I base size of arrays on annother number?
    By Dual-Catfish in forum C++ Programming
    Replies: 15
    Last Post: 09-25-2001, 01:31 PM