Error: 'serialize' : illegal qualified name in member declaration

This is a discussion on Error: 'serialize' : illegal qualified name in member declaration within the C++ Programming forums, part of the General Programming Boards category; Feh, I'm trying to serialize a class and failing because of a curious error, heres the code: Code: #include <boost/archive/text_iarchive.hpp> ...

  1. #1
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964

    Error: 'serialize' : illegal qualified name in member declaration

    Feh, I'm trying to serialize a class and failing because of a curious error, heres the code:
    Code:
    #include <boost/archive/text_iarchive.hpp>
    #include <boost/archive/text_oarchive.hpp>
    #include <boost/serialization/base_object.hpp>
    
    
    class CObject
    {
    
    public:
    	CObject(){}
    
    	virtual void Create()
    	{}
    
    	virtual void Access()
    	{}
    
    	virtual void Delete()
    	{delete this;}
    
    private:
    	virtual void Save_to_Disk(std::string Filename)
    	{}
    	
    	virtual void Read_File(std::string Filename)
    	{}
    	friend class boost::serialization::access;
    	template<class Archive>
    	virtual void boost::serialization::serialize(Archive & ar, const unsigned int version){};
    };
    Does anyone have any Idea what this means? I think it might have something to do with the template thing and the parameter Archive & ar, namespace issues perhaps?
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  2. #2
    Massively Single Player AverageSoftware's Avatar
    Join Date
    May 2007
    Location
    Buffalo, NY
    Posts
    141
    Code:
    	template<class Archive>
    	virtual void boost::serialization::serialize(Archive & ar, const unsigned int version){};
    The problem is here.
    I don't think this means what you think it means.

    In fact, what do you think it means?
    There is no greater sign that a computing technology is worthless than the association of the word "solution" with it.

  3. #3
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    Well, it looks like its declaring a template of type Archive... I guess the only trouble is I kinda expected boost to have one of these. I do find it strange that archive doesn't have anything in it. Maybe I need to define an archive class there? I'm honestly not sure what that code means because I'm trying to implement a part of boost I've never used before. But maybe you can tell me? That is why I'm here
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  4. #4
    Massively Single Player AverageSoftware's Avatar
    Join Date
    May 2007
    Location
    Buffalo, NY
    Posts
    141
    The compiler thinks you're declaring a member template, and the name you're giving it isn't legal.

    I don't know anything about Boost, so I'm not sure what exactly you're trying to accomplish. The only thing that I can think of might be that your friend class is expecting a callback method called serialize, in which case you should strip off the boost::serialization:: qualification.

    Perhaps someone that is familiar with Boost can give you a better answer.
    There is no greater sign that a computing technology is worthless than the association of the word "solution" with it.

  5. #5
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    Nice, I changed the code a bit because I read more about how boost works with derived classes, so the new code is:

    Code:
    class CObject
    {
    
    public:
    	CObject(){}
    
    	virtual void Create()
    	{}
    
    	virtual void Access()
    	{}
    
    	virtual void Delete()
    	{delete this;}
    
    private:
    	virtual void Save_to_Disk(std::string Filename)
    	{}
    	
    	virtual void Read_File(std::string Filename)
    	{}
    	friend class boost::serialization::access;
    	template<class Archive>
    	void serialize(Archive & ar, const unsigned int version){};
    };
    Yeah, so you were right, I'm not familiar with callback methods, maybe I aught to read about those sometime.
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  2. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 09:57 AM
  3. Direct Music Illegal Static Member Call error
    By FwyWice in forum Game Programming
    Replies: 4
    Last Post: 11-30-2002, 05:14 PM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM
  5. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21