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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:40:17+00:00 2026-05-27T08:40:17+00:00

look at this code #include<iostream> using namespace std; //Shape is an Interface Class. No

  • 0

look at this code

#include<iostream>

using namespace std;

    //Shape is an Interface Class. No data and everything pure virtual
    class Shape {
    public:
      virtual void Area(int length, int breadth) = 0;
      virtual void Perimeter(int length, int breadth) = 0;
      //Note, no data
    };

    //Derived class - Inherits Shape as Public
    class Rectangle : public Shape {
    public:
      void Area(int length, int breadth);
      void Perimeter(int length, int breadth);
    private:
      int someData;
    };

    //Derived class - Inherits Shape as Public
    class Triangle : public Shape {
    public:
      void Area(int length, int breadth);
      void Perimeter(int length, int breadth);
    private:
      int someData;
    };

    int main()
    {
      Rectangle r;
      Triangle t;

      cout<<"\n\n";
      r.Area(3,4);
      r.Perimeter(3,4);

      t.Area(3,4);
      t.Perimeter(3,4);

      cout<<"\n\n";
      return 0;
    }

    void Rectangle::Area(int length, int breadth)
    {
      cout<<"\nThe Area of Rectangle for length = "<<length<<" and\
      breadth = "<<breadth<<" is "<<(length * breadth)<<endl;
    }

    void Rectangle::Perimeter(int length, int breadth)
    {
      cout<<"\nThe Perimeter of Rectangle for length = "<<length<<" and\
      breadth = "<<breadth<<" is "<<2 * (length + breadth)<<endl;
    }

    void Triangle::Area(int length, int breadth)
    {
      cout<<"\nThe Area of Triangle for length = "<<length<<" and\
      breadth = "<<breadth<<" is "<<(length * breadth)/2<<endl;
    }

    void Triangle::Perimeter(int length, int breadth)
    {
      cout<<"\nThe Perimeter of Triangle for length = "<<length<<" and\
      breadth = "<<breadth<<" is "<<(length * breadth)/3<<endl;
    }

I use interface in the code , but my question is what i should use it and what is the benefits from it , no performance , no real needed it , why i should i use it ( the interfaces ) . what is the point to use it , an you explain it please .

and thank you !

  • 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-27T08:40:17+00:00Added an answer on May 27, 2026 at 8:40 am

    Abstract interfaces separate the interface from the implementation. Just as pimpl idiom it

    • decreases compilation time, and
    • lets you change the implementation without breaking the ABI.

    Both are important advantages in large programs.

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

Sidebar

Related Questions

Take a look at this code: #include <iostream> using namespace std; class A {
Have a look at this code: #include <iostream> using namespace std; int main() {
Please take a look at following code: #include <stdio.h> #include <iostream> using namespace std;
i have following code for heapsort #include <iostream> using namespace std; void exch(int a[],int
Take a look at this code: public class Test { public static void main(String...
Please take a look at this code: template<class T> class A { class base
take a look at this example code: public class Comment { private Comment() {
I have these C++ headers #include <iostream> #include istruttore.h #define max 30 using namespace
Please have a look on this code: #include <unistd.h> #include <stdlib.h> #include <stdio.h> int
Possible Duplicate: Calling virtual functions inside constructors Look at this code. In the constructor

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.