Serialization problem

This is a discussion on Serialization problem within the C++ Programming forums, part of the General Programming Boards category; I am trying to make a Serialization Class here the code follows. serialize.h http://pastebin.com/f1e82ff7f Code: //serialize.h #ifndef SERIALIZE_H #define SERIALIZE_H ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    219

    Serialization problem

    I am trying to make a Serialization Class here the code follows.

    serialize.h http://pastebin.com/f1e82ff7f
    Code:
    //serialize.h
    #ifndef SERIALIZE_H
    #define SERIALIZE_H
    
    #include <fstream>
    #include <iostream>
    #include <string>
    #include <typeinfo>
    #include "serializationexception.h"
    
    using std::string;
    using std::ofstream;
    using std::ifstream;
    using std::ios;
    using std::ios_base;
    
    template <class T>
    class Serialization{
    	public:
    		static T load(const string&)        throw(SerializationException, fileUnAccessible, fileUnReadable);
    		static void store(T, const string&) throw(SerializationException, fileUnAccessible, failedToWrite);
    };
    
    #endif
    serialize.cpp http://pastebin.com/f4d7fc1fa
    Code:
    //serialize.cpp
    #include "serialize.h"
    
    template <class T>
    T Serialization<T>::load(const string& fileName) throw(SerializationException, fileUnAccessible, fileUnReadable){
    	ifstream srzFStream(fileName.c_str(), ios_base::binary);
    	if(srzFStream.fail()){
    		throw fileUnAccessible(typeid(T).name(), fileName);
    	}
    	T obj;
    	srzFStream.read((char*)obj, sizeof(obj));
    	return obj;
    }
    
    template <class T>
    void Serialization<T>::store(T obj, const string& fileName) throw(SerializationException, fileUnAccessible, failedToWrite){
    	ofstream srzFStream(fileName.c_str(), ios_base::binary);
    	if(srzFStream.fail()){
    		throw fileUnAccessible(typeid(obj).name(), sizeof(obj), fileName);
    		return;
    	}
    	srzFStream.write((char*)obj, sizeof(obj));
    	if(srzFStream.fail()){
    		throw failedToWrite(typeid(obj).name(), sizeof(obj), fileName);
    		return;
    	}
    }
    and on the main() I want to use it in this way.
    main()
    Code:
    //main()
    string y,x="Neel Basu";
    Serialization<string>::store(x, "/home/neel/Desktop/name.srl");//Line 51
    y=Serialization<string>::load("/home/neel/Desktop/name.srl");//Line 52
    But I get Linker Error from main()
    Code:
    /home/neel/dev.cpp/web/src/web.cpp:51: undefined reference to `Serialization<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::store(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
    /home/neel/dev.cpp/web/src/web.cpp:52: undefined reference to `Serialization<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::load(std::basic_string<char, std::char_traits<char>
    serialize.h is include in the file that contains the main() and It also builds the serialize.o Object Module too But Cant find the reference to the methods.
    I cant understand why any Help Please.
    Thank you.
    Last edited by noobcpp; 07-14-2008 at 11:44 AM.

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    You may be compiling all of the source files (i.e., generating .o files for each .cpp file), but are you linking them all together? Can you describe how you're compiling the code? If you're using g++, you'll want something like this to link the object files into one executable:
    Code:
    g++ web.o serialize.o -o program
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    219
    I am using automake and I am building all the .o
    and then combining all while linking.
    Code:
    g++ -O0 -g3 -o web web.o request.o httpheader.o apprequest.o httputil.o serialize.o serializationexception.o
    and then it fires the following Error:
    Code:
    g++ -O0 -g3 -o web web.o request.o httpheader.o apprequest.o httputil.o serialize.o serializationexception.o 
    web.o: In function `main':
    /home/neel/dev.cpp/web/src/web.cpp:51: undefined reference to `Serialization<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::store(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
    /home/neel/dev.cpp/web/src/web.cpp:52: undefined reference to `Serialization<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::load(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
    collect2: ld returned 1 exit status
    make[2]: *** [web] Error 1
    make[1]: *** [all-recursive] Error 1
    make: *** [all] Error 2
    *** Exited with status: 2 ***
    and it doesnt show any error while making the serialize.o Object
    Code:
    if g++ -DHAVE_CONFIG_H -I. -I/home/neel/dev.cpp/web/src -I.. -I/home/neel/dev.cpp/web/src -O0 -g3 -MT serialize.o -MD -MP -MF ".deps/serialize.Tpo" -c -o serialize.o /home/neel/dev.cpp/web/src/serialize.cpp; then mv -f ".deps/serialize.Tpo" ".deps/serialize.Po"; else rm -f &qu
    is successfull

    **However I am using KDevelop IDE
    Last edited by noobcpp; 07-14-2008 at 01:12 PM.

  4. #4
    Registered User
    Join Date
    Jun 2007
    Posts
    219
    Notice that load() and store() methods are static.
    so do I need to use extern or something else ??

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    It looks like the code from serialize.cpp isn't being linked into your executable for some reason, because the functions defined in that source file cannot be found by the linker.

    I'm not really sure what's going on here. I'm pretty sure that the order of .o objects passed to g++ doesn't matter (unlike libraries). Perhaps a source file isn't being recompiled, but that shouldn't happen with automake.

    The only thing I can suggest is to rebuild the whole thing, which you've probably already tried.
    Code:
    automake && autoconf
    ./configure
    make clean
    make
    Using KDevelop shouldn't make any difference.

    [edit] extern isn't necessary here.

    If you want to test whether my theory of serialize.cpp not being included is correct, temporarily move the code from serialize.cpp to the end of the source file that main() is in. That should compile, but if it does, it means that serialize.cpp isn't being compiled . . . .

    Can you post your autoconf and automake files? Not the generated ones, the input ones, like configure.in or configure.ac, and Makefile.am. [/edit]
    Last edited by dwks; 07-14-2008 at 01:26 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User
    Join Date
    Jun 2007
    Posts
    219
    Code:
    which you've probably already tried.
    Yes LOL
    Now I'll delete the serialize.o and web.o hard file along with make clean and friends too. and try

  7. #7
    Registered User
    Join Date
    Jun 2007
    Posts
    219
    LOL Nope Its showing the same error again

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    You're not messing around with namespaces, are you? I don't see any in your header file, but they could cause this sort of problem.

    What happens if you compile some of the source files by hand, say web.cpp and serialize.cpp, and link them yourself?

    If you're willing to post all of your code online (or PM it to me if you like), I could try compiling it for you. Assuming I can get onto a Linux computer, which isn't the case at the moment.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    Registered User
    Join Date
    Jun 2007
    Posts
    219
    No My code doesnt use any Namespace But I use the standered std namespace.
    However I've done one more research on it never thought that I'll use geeky tools Like nm and objdump. I dont have much knowledge on them too.
    I was testing wheather or not the serialize.o contains the load() and store methods. but I dont see that serialize.o contains those load() and store() methods may be thats due to static may be I donno how to see the nm or objdumpo output.

    Code:
    neel@zigmoyd:~/dev.cpp/web/debug/src$ nm -f sysv serialize.o
    Symbols from serialize.o:
    Name                  Value   Class        Type         Size     Line  Section
    
    __cxa_atexit        |        |   U  |            NOTYPE|        |     |*UND*
    __dso_handle        |        |   U  |            NOTYPE|        |     |*UND*
    _GLOBAL__I__home_neel_dev.cpp_web_src_serialize.cpp_8D2A3925_E47834CC|00000046| t  |    FUNC|00000017|     |.text
    __gxx_personality_v0|        |   U  |            NOTYPE|        |     |*UND*
    __tcf_0             |0000005e|   t  |              FUNC|00000014|     |.text
    _Z41__static_initialization_and_destruction_0ii|00000000|   t  |              FU                                              NC|00000045|     |.text
    _ZNSt8ios_base4InitC1Ev|        |   U  |            NOTYPE|        |     |*UND*
    _ZNSt8ios_base4InitD1Ev|        |   U  |            NOTYPE|        |     |*UND*
    _ZSt8__ioinit       |00000000|   b  |            OBJECT|00000001|     |.bss
    Code:
    neel@zigmoyd:~/dev.cpp/web/debug/src$ objdump -St serialize.o
    
    serialize.o:     file format elf32-i386
    
    SYMBOL TABLE:
    00000000 l    df *ABS*  00000000 serialize.cpp
    00000000 l    d  .text  00000000 .text
    00000000 l    d  .data  00000000 .data
    00000000 l    d  .bss   00000000 .bss
    00000000 l    d  .debug_abbrev  00000000 .debug_abbrev
    00000000 l    d  .debug_info    00000000 .debug_info
    00000000 l    d  .debug_line    00000000 .debug_line
    00000000 l    d  .debug_macinfo 00000000 .debug_macinfo
    00000000 l    d  .ctors 00000000 .ctors
    00000046 l     F .text  00000017 _GLOBAL__I__home_neel_dev.cpp_web_src_serialize.cpp_8D2A3925_E47834CC
    00000000 l     F .text  00000045 _Z41__static_initialization_and_destruction_0ii
    00000000 l     O .bss   00000001 _ZSt8__ioinit
    0000005e l     F .text  00000014 __tcf_0
    00000000 l    d  .debug_frame   00000000 .debug_frame
    00000000 l    d  .eh_frame      00000000 .eh_frame
    00000000 l    d  .debug_loc     00000000 .debug_loc
    00000000 l    d  .debug_aranges 00000000 .debug_aranges
    00000000 l    d  .debug_str     00000000 .debug_str
    00000000 l    d  .note.GNU-stack        00000000 .note.GNU-stack
    00000000 l    d  .comment       00000000 .comment
    00000000         *UND*  00000000 _ZNSt8ios_base4InitC1Ev
    00000000         *UND*  00000000 __dso_handle
    00000000         *UND*  00000000 __cxa_atexit
    00000000         *UND*  00000000 __gxx_personality_v0
    00000000         *UND*  00000000 _ZNSt8ios_base4InitD1Ev
    
    
    Disassembly of section .text:
    
    00000000 <_Z41__static_initialization_and_destruction_0ii>:
            if(srzFStream.fail()){
                    throw failedToWrite(typeid(obj).name(), sizeof(obj), fileName);
                    return;
            }
    }
       0:   55                      push   %ebp
       1:   89 e5                   mov    %esp,%ebp
       3:   83 ec 18                sub    $0x18,%esp
       6:   89 45 fc                mov    %eax,0xfffffffc(%ebp)
       9:   89 55 f8                mov    %edx,0xfffffff8(%ebp)
       c:   83 7d fc 01             cmpl   $0x1,0xfffffffc(%ebp)
      10:   75 31                   jne    43 <_Z41__static_initialization_and_destruction_0ii+0x43>
      12:   81 7d f8 ff ff 00 00    cmpl   $0xffff,0xfffffff8(%ebp)
      19:   75 28                   jne    43 <_Z41__static_initialization_and_destruction_0ii+0x43>
    #endif
      //@}
    
      // For construction of filebuffers for cout, cin, cerr, clog et. al.
      static ios_base::Init __ioinit;
      1b:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
      22:   e8 fc ff ff ff          call   23 <_Z41__static_initialization_and_destruction_0ii+0x23>
      27:   c7 44 24 08 00 00 00    movl   $0x0,0x8(%esp)
      2e:   00
      2f:   c7 44 24 04 00 00 00    movl   $0x0,0x4(%esp)
      36:   00
      37:   c7 04 24 5e 00 00 00    movl   $0x5e,(%esp)
      3e:   e8 fc ff ff ff          call   3f <_Z41__static_initialization_and_destruction_0ii+0x3f>
      43:   c9                      leave
      44:   c3                      ret
      45:   90                      nop
    
    00000046 <_GLOBAL__I__home_neel_dev.cpp_web_src_serialize.cpp_8D2A3925_E47834CC>:
      46:   55                      push   %ebp
      47:   89 e5                   mov    %esp,%ebp
      49:   83 ec 08                sub    $0x8,%esp
      4c:   ba ff ff 00 00          mov    $0xffff,%edx
      51:   b8 01 00 00 00          mov    $0x1,%eax
      56:   e8 a5 ff ff ff          call   0 <_Z41__static_initialization_and_destruction_0ii>
      5b:   c9                      leave
      5c:   c3                      ret
      5d:   90                      nop
    
    0000005e <__tcf_0>:
      5e:   55                      push   %ebp
      5f:   89 e5                   mov    %esp,%ebp
      61:   83 ec 08                sub    $0x8,%esp
      64:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
      6b:   e8 fc ff ff ff          call   6c <__tcf_0+0xe>
      70:   c9                      leave
      71:   c3                      ret
    Last edited by noobcpp; 07-15-2008 at 12:44 PM.

  10. #10
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    I can send you my email address if you like, but it's easier if you just send me a private message with your code or whatever. You can attach any file extension if you add .c or .txt onto the end. (i.e., rename code.zip to code.zip.txt and you can attach it.)

    [edit] Just try compiling serialize.cpp yourself. cat it, make sure you have the right version. As you can see here, your basic idea should be working.
    Code:
    $ ls
    one.cpp  serialize.cpp  serialize.h
    $ cat one.cpp
    #include "serialize.h"
    
    int main() {
        serial::f1();
        serial::f2();
    
        return 0;
    }
    $ cat serialize.cpp
    #include <iostream>
    #include "serialize.h"
    
    void serial::f1() {
        std::cout << "f1()\n";
    }
    
    void serial::f2() {
        std::cout << "f2()\n";
    }
    $ cat serialize.h
    class serial {
    public:
        static void f1();
        static void f2();
    };
    $ g++ *.cpp -o noobcpp
    $ ./noobcpp
    f1()
    f2()
    $
    [/edit]
    Last edited by dwks; 07-14-2008 at 02:09 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  11. #11
    Registered User
    Join Date
    Jun 2007
    Posts
    219
    However I'll be glad If you send me your email address.
    I've filtered the Project and removed unnecessary Classes and files and made this KDevelop Project.
    Its in a tar.gz archive containing a srz.kdevelop in it.
    Not to mention that It also gives that same Error LOL however different LIne Numbers cause I've removed some OffTopic Classes.
    However I dont find the Option to Upload Files in PM so I've uploaded it in rapidshare plese download it from there.
    http://rapidshare.com/files/129694700/srz.tar.gz.html

  12. #12
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    I'm working on it. Your build system doesn't seem to be the problem -- compiling it by hand generates the same errors -- though your clock is in the future compared to mine, so I had to run "touch $(find)" to get it to work.

    Haven't figured out what the problem is yet.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  13. #13
    Registered User
    Join Date
    Jun 2007
    Posts
    219
    Quote Originally Posted by dwks View Post
    I'm working on it. Your build system doesn't seem to be the problem -- compiling it by hand generates the same errors -- though your clock is in the future compared to mine, so I had to run "touch $(find)" to get it to work.

    Haven't figured out what the problem is yet.
    Thank you very much for your help.

    My Clock Is in future LOL What a nice word.
    You are from US/west ??

  14. #14
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Canada, actually -- but yes.

    By the way:
    Code:
    httputil.cpp: In function ‘int UrlEncode(const char*, char*, unsigned int)’:
    httputil.cpp:90: error: ‘strchr’ was not declared in this scope
    httputil.cpp: In function ‘std::string UrlDecodeString(const std::string&)’:
    httputil.cpp:113: error: ‘malloc’ was not declared in this scope
    httputil.cpp:117: error: ‘free’ was not declared in this scope
    httputil.cpp: In function ‘std::string UrlEncodeString(const std::string&)’:
    httputil.cpp:126: error: ‘malloc’ was not declared in this scope
    httputil.cpp:130: error: ‘free’ was not declared in this scope
    You need to include <cstring> and <cstdlib> there, and have using directives, for those functions as well.

    The problem must be with your build system. This sample code compiles just fine:
    Code:
    #include <iostream>
    
    template <typename T>
    class basic {
    public:
        static void function(T x);
    };
    
    template <typename T>
    void basic<T>::function(T x) {
        std::cout << x << std::endl;
    }
    
    int main() {
        basic<int>::function(3);
        return 0;
    }
    When I put the class declaration in serialization.h, the code for function() in serialization.cpp, and the function call in main(), it doesn't compile.
    Code:
    /home/dwk/down/noobcpp/srz/src/srz.cpp:39: undefined reference to `basic<int>::function(int)'
    However, when I put the code for function() in srz.cpp, it does compile.

    I think putting the code for those static functions into srz.cpp would make it compile, as well.

    Unfortunately, I'm out of time. Good luck.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  15. #15
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Hmm, your program compiles if I add the following onto the end of srz.cpp, and remove everything from serialization.cpp:
    Code:
    template <class T>
    T Serialization<T>::load(const string& fileName) throw(SerializationException, fileUnAccessible, fileUnReadable){
            ifstream srzFStream(fileName.c_str(), ios_base::binary);
            if(srzFStream.fail()){
                    //throw fileUnAccessible(typeid(T).name(), fileName);
            }
            T obj;
            srzFStream.read((char*)&obj, sizeof(obj));
            return obj;
    }
    
    template <class T>
    void Serialization<T>::store(T obj, const string& fileName) throw(SerializationException, fileUnAccessible, failedToWrite){
            ofstream srzFStream(fileName.c_str(), ios_base::binary);
            if(srzFStream.fail()){
                    //throw fileUnAccessible(typeid(obj).name(), sizeof(obj), fileName);
                    return;
            }
            srzFStream.write((char*)&obj, sizeof(obj));
            if(srzFStream.fail()){
                    //throw failedToWrite(typeid(obj).name(), sizeof(obj), fileName);
                    return;
            }
    }
    The strange thing is that the commented-out throws give errors when this code is in srz.cpp. (failedToWrite() has only a default constructor, so of course it gives an error.) Yet, in serialization.cpp, the same code gives no errors at all.

    The same thing happens if I compile the code by hand.

    So it seems like serialization.cpp is jinxed or something. I created new.cpp, a new source file to hold the bodies of those two static functions. I got the same errors.

    Moving main() to new.cpp, and leaving the function bodies in srz.cpp, creates the same errors. Grr. So main() has to be in the same file as those functions?

    By the way, I finally got your code to compile by using this for serialization.h:
    Code:
    /***************************************************************************
     *   Copyright (C) 2008 by Neel Basu   *
     *   neel@zigmoyd   *
     *                                                                         *
     *   This program is free software; you can redistribute it and/or modify  *
     *   it under the terms of the GNU General Public License as published by  *
     *   the Free Software Foundation; either version 2 of the License, or     *
     *   (at your option) any later version.                                   *
     *                                                                         *
     *   This program is distributed in the hope that it will be useful,       *
     *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
     *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
     *   GNU General Public License for more details.                          *
     *                                                                         *
     *   You should have received a copy of the GNU General Public License     *
     *   along with this program; if not, write to the                         *
     *   Free Software Foundation, Inc.,                                       *
     *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
     ***************************************************************************/
    #ifndef SERIALIZATION_H
    #define SERIALIZATION_H
    
    #include <fstream>
    #include <iostream>
    #include <string>
    #include <typeinfo>
    #include "serializationexception.h"
    
    using std::string;
    using std::ofstream;
    using std::ifstream;
    using std::ios;
    using std::ios_base;
    
    template <class T>
    class Serialization{
    	public:
    		//static T load(const string&)					throw(SerializationException, fileUnAccessible, fileUnReadable);
    		//static void store(T, const string&)		throw(SerializationException, fileUnAccessible, failedToWrite);
                    
    static T load(const string& fileName) throw(SerializationException, fileUnAccessible, fileUnReadable){
            ifstream srzFStream(fileName.c_str(), ios_base::binary);
            if(srzFStream.fail()){
                    //throw fileUnAccessible(typeid(T).name(), fileName);
            }
            T obj;
            srzFStream.read((char*)&obj, sizeof(obj));
            return obj;
    }
    
    static void store(T obj, const string& fileName) throw(SerializationException, fileUnAccessible, failedToWrite){
            ofstream srzFStream(fileName.c_str(), ios_base::binary);
            if(srzFStream.fail()){
                    //throw fileUnAccessible(typeid(obj).name(), sizeof(obj), fileName);
                    return;
            }
            srzFStream.write((char*)&obj, sizeof(obj));
            if(srzFStream.fail()){
                    //throw failedToWrite(typeid(obj).name(), sizeof(obj), fileName);
                    return;
            }
    }
    
    };
    
    #endif
    So I guess your two functions have to be inline, in the header file, or visible from where they are declared. Someone more versed in C++ probably could have told you that immediately and why . . . .
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM

Tags for this Thread


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