Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 733929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:18:48+00:00 2026-05-14T07:18:48+00:00

a bit of a vague question but I am looking for pointers as to

  • 0

a bit of a vague question but I am looking for pointers as to how can I generate String diff vectors in C++. The scenario is such that given a paragraph I want to store the various differences(Edit, cut copy paste etc.) it goes through in a draft mode to review Audit history.

Any hints in this regard will be really appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:18:48+00:00Added an answer on May 14, 2026 at 7:18 am

    An idea using C++ polymorphism:

    class Action
    {
        public:
        virtual void revert(std::string& base) = 0;
    };
    
    class InsertAction : public Action
    {
        private:
        int pos, len;
        public:
        InsertAction(int pos, std::string& base, const std::string& in) : len(in.size()), pos(pos)
        {
            base.insert(pos, in);
        }
    
        virtual void revert(std::string& base)
        {
            base.erase(pos,len);
        }
    };
    
    int main()
    {
        std::string text("hello !");
        std::cout << text << std::endl;
        Action* action = new InsertAction(5, text, " world");
        std::cout << text << std::endl;
        action->revert(text);
        std::cout << text << std::endl;
        delete action;
    }
    

    You can then add and pop Actions from a LIFO queue as you want. It’s a simple example, you could also try to link it more to a string instead of always passing at as a param, but that’s up to your own design. I know it’s not ‘real’ diffing, but I think this solution to be closer coupled to the problem then really storing general string differences.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a bit of a vague question I realise, but I've been looking
Apologies if this is a bit vague, but that's half of the problem. I
I did a fair bit of searching for an answer to this question, but
I'm looking for an algorithm that does some sort of page ranking, but gives
I'm sorry this question is going to be a bit vague because I'm not
This may be a bit silly question, but I just started doing pretty things
Good day good-looking computer people, I might be asking a bit too much, but
sorry ma question went wrong a bit the alis has value like alias =Sri
The W3C definition seems a bit vague when it comes to the <nav> tag:
Probably the following description of the issue I'm encountering will be a bit vague,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.