CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Join Date
    Jun 2004
    Posts
    1,352

    Re: MFC and STD::STRING not compatable ???

    Ok,

    Thank you very much. I do appreciate your answer, it will keep me from going down the wrong road.

    I will take your advice and get a more up to date book.

    If you could recommend one , I would appreciate that too.

    ...I knew I would get a quick answer to my question. Thanks again guys.
    Rate this post if it helped you.

  2. #17
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: MFC and STD::STRING not compatable ???

    Book: Object Oriented Programing in C++ : Third Edition, By Robert Lafore.
    I haven't got the 3rd edition, but in the 4th edition in chapter 12 in the section File I/O With Member Functions, it shows an example using this type of file read/write. However, this example uses a class that doesn't use dynamic memory - just integral types and arrays of integral types. For these data types, this method of file read/write will be OK (if virtual functions are not used). The issue with this method is when a class/struct uses dynamic memory.

    My current favourite C++ introduction book is Beginning C++17 From Novice To Professional by Ivor Horton. See https://www.amazon.co.uk/Beginning-C...s=books&sr=1-6

    Note the the new C++20 standard has now been just about formalised and will be published later this year. His new book covering C++20 will be published early 2021. See https://www.amazon.co.uk/Beginning-C...68FEC0833EE142

    For an on-line resource, have a look at https://www.learncpp.com/

    For an intermediate C++ book, consider Professional C++ by CodeGuru's own Marc Gregoire. See https://www.amazon.co.uk/Professiona...s%2C216&sr=1-1

    Note. These links are for the current version of these books. They all have previous versions - often at substantial savings for second hand versions. Please don't be tempted. When you're learning, I always recommend using a book that covers the current/future C++ standard. This changes every 3 years. C++11, C++14, currently C++17 and shortly C++20.

    For a reference site for C++, see https://en.cppreference.com/w/cpp
    Last edited by 2kaud; May 6th, 2020 at 03:05 PM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #18
    Join Date
    Jun 2004
    Posts
    1,352

    Re: MFC and STD::STRING not compatable ???

    Thank You Very Much , I do appreciate that.

    btw, its been a long time since I have come around here and I do appreciate you guys are still around. I have always and will always consider you guys "VERY SOUND IF NOT EXPERT ADVISORS".


    Quick question, that system logs me out after only a few minutes, back in the day I could stay logged on all day. Have you changed your policy or do I have to do something in my settings?
    Rate this post if it helped you.

  4. #19
    Join Date
    Jun 2004
    Posts
    1,352

    Re: MFC and STD::STRING not compatable ???

    I did some research on shallow vs deep copying. It explains what is happening.

    Im sticking with plain old C to do my file transfers to and from disk: i.e. , fopen,fread, fwrite. You can't copy any harder than that, no pun intended.

    I'm a C/MFC programmer, Most of the stuff in C++ I can do in C.


    As fore thought to the future of C++

    I would have expected that C++ would have figured out how to automatically write objects with dynamic memory pointers. Microsofts Access DataBase writes Tables that contain CStrings. It wouldn't be too difficult to write a standard for databases that contain fields with dynamic memory pointers.

    I wrote my own data base with variable length strings, each dynamic string is written as a linked list of records, and each record in the file is either a Struct Record or StringRecord. Each String record has Record type identifier, Parent DataRecord identifier and Segment Identifier. All records in the file are either Data Records or String segment records.

    It would not be very difficult to standardize such a File Transfer Protocol for Classes that contain variable length fields?

    I slightly remember from the beginning days of C++ people complaining about PERSISTANCE, I'm still not 100% sure what the term means though as I"m very happy with C and only use the basic features of C++ .


    Don't get me wrong, I'm very appreciative of your answers, it just something I would like to bounce off of a person who has kept up with C++.


    Again , Thank You for your answers and getting me pointed in the right direction.
    Rate this post if it helped you.

  5. #20
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: MFC and STD::STRING not compatable ???

    This process of writing data and objects to a file (or socket etc) so that they can be reconstructed later in the memory of the same or another computing host is called serialization. The reconstruction process is known as deserialization. MFC offers some support for this, but standard C++ does not. Boost (a well-known set of libraries for C++) offers a serialization library (https://www.boost.org/doc/libs/1_72_...doc/index.html) and there are other 3rd party libraries available to do this. Just do an internet search for C++ serialization.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #21
    Join Date
    Jun 2004
    Posts
    1,352

    Re: MFC and STD::STRING not compatable ???

    Thank You,

    I will look into that.
    Rate this post if it helped you.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured