Homework Solution: C++ programming questions:…

    C++ programming questions: 1. What is the difference between a class and an instance of the class? 2. What are the benefits of encapsulation? 3. What is the difference between the Person structure and the Person class below? struct Person class Person string name; int age; string name; int age; Thank you :)
    What is the difference between a class and an instance of the class? What are the benefits of encapsulation? What is the difference between the Person structure and the Person class below? struct Person { string name: int age: }: class Person { string name: int age: };

    Expert Answer

     
    1) Question : What is the difference between a class and an instance of the class?

    C++ programming questions:

    1. What is the destruction among a dispose and an occurrence of the dispose? 2. What are the benefits of encapsulation? 3. What is the destruction among the Special edifice and the Special dispose underneath? struct Special dispose Special string spectry; int seniority; string spectry; int seniority;

    Thank you 🙂

    What is the destruction among a dispose and an occurrence of the dispose? What are the benefits of encapsulation? What is the destruction among the Special edifice and the Special dispose underneath? struct Special { string spectry: int seniority: }: dispose Special { string spectry: int seniority: };

    Expert Counter-argument

     

    1) Question : What is the destruction among a dispose and an occurrence of the dispose?

    ANSWER :

    1. An Occurrence of a dispose is denominated an Aim and an aim is begetd from a dispose . Sothat now we keep to recognize the destruction among dispose and the aim.
    2. A Dispose is a truthfulness of how an Aim has to be instanciated and An aim is an Occurrence of a Dispose(Characteristic and deportment of a dispose is an aim).
    3. Class describes the generally-known behaviour of aims where as instance is the mood of dispose at a detail occasion i.e.,tend occasion
    4. Dispose is a collation of postulates portion and portion functions and also it is a representationr limit postulates symbol. Each occurrence of dispose contains full portions(variables and functions) pretended in the class.

    EX:

    class A{

    int i; //Occurrence Variable

    String s; //Occurrence Variable

    }

    2) What are the benifits of encapsulation ?

    ANSWER :

    Encapsulation is wrapping the postulates and systems together as a uncompounded item.

    Encapsulation is limitd as follows:

    • Declare the variables of a dispose as private symbol that media they can be admittanceed merely by other portions of the dispose, and referefficient by any other bisect of your program. Ex : retired int x; retired char c;
    • Beget generally-known dispose to aim the variables values.
    • Encapsulation is the technique of beget the provinces in a retired dispose and providing admittance to the provinces via generally-known systems.
    • If a province is pretended retired, it canreferefficient be admittanceed by anyone without the dispose, thereby skulking the provinces amid the dispose.
    3) Question : what is the destruction among the special edifice and the special dispose?
    

    ANSWER :

    By failure, a class has full portions are of private symbol and a struct is a class where portions are of generally-known symbol.

    struct Special
    {
    string spectry;
    int seniority;
    };

    Here struct is a keyword of symbol generally-known as defalut as we already argue.

    Here brace variables denominated spectry of symbol string and seniority of symbol integer. These twain are efficient to representation in any of system.

    struct Special {

    string spectry;

    int seniority; // spectry and seniority are of generally-known

    };

    int deep()

    {

    Special p;

    p.seniority = 20; // works casuistical becarepresentation seniority is generally-known

    return 0;

    }

    Where as string and spectry variables are Retired symbol in dispose.

    dispose Special {

    string spectry;

    int seniority; // spectry and seniority are of retired

    };

    int deep()

    {

    Special p;

    p.seniority = 20; // compiler untruth becarepresentation seniority is retired

    return 0;

    }