Welcome, Guest. Please login or register.

Author Topic: Learning C with the Amiga  (Read 32550 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Sys_64738

  • Newbie
  • *
  • Join Date: Jan 2007
  • Posts: 3
    • Show all replies
Re: Learning C with the Amiga
« on: February 08, 2007, 12:00:46 AM »
@koaftder:

Regard MFC serialization, it is the *framework* (MFC framework) that helps you in serialization work, providing a pre-built infrastructure for serialization.

So you can simply add a Serialize() virtual method to your custom class (deriving it from CObject), and simply use operators << and >> for serialization.

This can be done recursively, also for classes containing structures, and for structures containing nested structures, etc.
(The important thing is that the object is "serializable", i.e. it must provide a Serialize() method, etc.)

This is not possible in C because C does not offer operator-overloading and virtual functions and polymorphism and late-binding at the level of C++ (even if these things may be done also in C, but at the expense of writing more code).

However, C++ has not built-in serialization mechanism. It is the framework you use (e.g. MFC) that can provide one (and if you follow the framework rules, you can have serialization for your own classes fairly simply).

Maybe C++ Boost libraries offer another serialization mechanism (more standard than the MFC-specific one).

 

Offline Sys_64738

  • Newbie
  • *
  • Join Date: Jan 2007
  • Posts: 3
    • Show all replies
Re: Learning C with the Amiga
« Reply #1 on: February 08, 2007, 09:31:35 AM »
@Karlos

Quote

There's nothing "specific" in the STL or anything for data serialization


If we somehow consider Boost an STL++ (and in fact Boost is a widely accepted standard in C++ programmers community), you may find this useful:

http://www.boost.org/libs/serialization/doc/index.html


Quote

class StreamStorable {

  public:
    virtual bool write(OutputStream& s) = 0;
    virtual bool read(InpputStream& s) = 0;

}


Is this not complete right?
Defining an interface class without a virtual destructor is an invitation to disasters :-)


 

Offline Sys_64738

  • Newbie
  • *
  • Join Date: Jan 2007
  • Posts: 3
    • Show all replies
Re: Learning C with the Amiga
« Reply #2 on: February 09, 2007, 09:13:35 PM »
Quote

lou_dias wrote:
In that case, the USA is not a 1st world country.
Healthcare costs are quite a political debate around here. :(


USA is a great country, very advanced in technology and science.

But I really can't understand why you don't have a "public" health system.
Don't you think that human health (as education, etc.) should be rights for everyone??!?