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 7523413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:47:44+00:00 2026-05-30T02:47:44+00:00

This is a sample code for memory mapped file share. The mapped_region is d

  • 0

This is a sample code for memory mapped file share.
The mapped_region is d class that is responsible for it
Now me before digging in deep I cant follow why such declaration are used. can any one please explain this to me ?

class mapped_region
{
   // Non-copyable
   mapped_region(const mapped_region &);

   // Non-assignable
   mapped_region &operator=(const mapped_region &);

   public:

   typedef /*implementation-defined*/ offset_t;
   typedef /*implementation-defined*/ accessmode_t;
   static const accessmode_t          invalid_mode;
   static const accessmode_t          read_only;
   static const accessmode_t          read_write;
   static const accessmode_t          copy_on_write;

   mapped_region();

   mapped_region( const memory_mappable & mappable
                , accessmode_t            mode
                , offset_t                mappable_offset
                , std::size_t             size = 0
                , const void *            address = 0);

   mapped_region(mapped_region &&other);

   std::size_t get_size() const;

   void*       get_address() const;

   offset_t    get_offset() const;

   accessmode_t get_mode() const;

   void flush(std::size_t region_offset = 0, std::size_t numbytes = 0);

   void swap(mapped_region &other);

   ~mapped_region();
};

In this example the

// Non-copyable
mapped_region(const mapped_region &); 

what does that mean ?

  • 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-30T02:47:46+00:00Added an answer on May 30, 2026 at 2:47 am

    Yes, it is possible to have a constructor with parameter name same as class.
    Two situations are possible:

    • Copy Constructor
    • Move Constructor

    In your code:

    mapped_region(const mapped_region &);
    

    represents a Copy Constructor, while:

    mapped_region(mapped_region &&other);
    

    represents a Move Constructor

    A copy constructor is used to create copies of your class object. Whenever you pass the class object as function argument by value or a copy of your class object is needed then the compiler calls the copy constructor to create this object.

    If you want to restrict the users of your class from making copies of your class object then you declare copying functions(copy constructor & copy assignment operator =) as private, and this is what your code does in this case it restricts users of your code from creating any copies of your class mapped_region. Note that the default access specifier for an class is private.

    Since your code declares a Move constructor, I assume you are using C++11 and hence a better way to achieve the desired functionality here is to use explicitly deleting special member functions provided in C++11.

    For Eg:

    class mapped_region{
        mapped_region & operator=(const mapped_region&) = delete;
        mapped_region(const mapped_region&) = delete;
        mapped_region() = default;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this sample code: <div class=containter id=ControlGroupDiv> <input onbeforeupdate=alert('bingo 0'); return false; onclick=alert('click 0');return
Given this sample code: #include <iostream> #include <stdexcept> class my_exception_t : std::exception { public:
I have this sample code for async operations (copied from the interwebs) public class
Background: Inspired from Apple's sample code ScrollViewSuite, I've created a view controller class that
edit It appears that this is just a case of the sample code being
In this sample code the URL of the app seems to be determined by
I've written this sample code to print the length of x. But for some
I'm reading this code sample : And since I don't know C#, I decided
In this particular code sample I want to reference the second overloaded method (int
In sample code, I have seen this: typedef enum Ename { Bob, Mary, John}

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.