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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:16:55+00:00 2026-06-11T20:16:55+00:00

Please tell me, if the following class is monomorphic? What makes it monomorphic? What

  • 0

Please tell me, if the following class is monomorphic?

What makes it monomorphic? What does monomorphic actually mean?

class Foo
{
public:
    Foo(int n)
    {
        this->m = n;
    }

    void print()
    {
        std::cout << this->m << std::endl;
    }

private:
    int m;
};

Edit:

in context of a class Boo:

class Boo
{
 public:
  Boo& Boo::operator=(const Boo &boo)
  {
     *foo1 = *boo.foo1;
     *foo2 = *boo.foo2;

     return *this;
  }

 private:
   Foo* foo1;
   Foo* foo2;
};
  • 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-06-11T20:16:56+00:00Added an answer on June 11, 2026 at 8:16 pm

    First, in order to answer this question, we need to examine what monomorphic really means. To do that, let’s break down the word:

    mono - morphic
    

    So, if we assume that mono = one and morphic = transformable (at least for this example – don’t kill me over dictionary semantics)

    So, we can take this to mean many things, here are a few off of the top of my head:

    1. Our class can only be changed once
    2. Or it could be used as the opposite to polymorphism (meaning that it cannot be subclassed)
    3. Finally, it could refer to the property of mathematics: http://en.wikipedia.org/wiki/Monomorphism

    So, assuming that that answer 3 isn’t what we are looking for (in which case you’d have to find a better answer because that article is confusing), let’s step through one and two.

    1. Our class can only be changed once

    In my opinion, this is the most likely meaning. At first glance, your object is monomorphic, meaning it can only be changed once, through the constructor (be that the designated constructor or the built-in copy constructor).

    In any computer that has memory that is read-write, this cannot be true, because there’s almost always a way to manually set the bits in memory, if you want / need to.

    However, barring from that scenario, using the interface you provided, then yes, your class is monomorphic in that it’s member (m) is only set through the constructor.

    2. Our class isn’t polymorphic

    The answer to this one is a bit complex. C++, unlike most languages, has two forms of polymorphism. In a traditional OO sense, it has the ability to create functions that are overwritten by a subclass, which would be marked as virtual. You do not do this, however, so OO polymorphism is NOT possible with your class.

    However, as I said earlier, there is more than one type of polymorphism available in C++. The second type is referred to as template polymorphism or function polymorphism, which is used throughout the STL (mainly for iterators), and it works a bit like this:

    template<typename aImpl>
    void printA(const aImpl &a)
    {
        a.print();
    }
    
    class A {
        public:
        void print() { puts("I'm in A!"); }
    };     
    

    Which is a perfectly valid interface, and it would work as expected. However, there is nothing to prevent the following class from being placed to the function:

    class B {
        public:
        void print() { puts("I'm in B!"); }
    };
    

    Which would obviously print a different value.

    In the end, C++ is a complex language, and if you truly want a class to be unable to be polymorphic, you need to have all members and functions be private, which defeats the purpose of having an object in the first place.

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

Sidebar

Related Questions

I have following UML class diagram and java coding for each, please tell me
I have the following code: class asd { public: int b; asd() { b
I have the following class class Node { int key; Node**Nptr; public: Node(int maxsize,int
Please tell me what the following sentence means in ' The Zen of Python
Please tell me if it is possible to do the following: create an instance
Please Check the following codes & please tell me about the error(s) I have
Could anyone please tell me why the following line about filter init method invocation
Could anyone please tell me why the following casting is resulting in compile time
Can someone please tell me how I can implement the following line of pseudo-code.
Can somebody please tell me what is wrong with the following pom.xml? i'm getting

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.