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 dissimilitude among a collocate and an illustration of the collocate? 2. What are the benefits of encapsulation? 3. What is the dissimilitude among the Individual construction and the Individual collocate adown? struct Individual collocate Individual string indicate; int seniority; string indicate; int seniority;

    Thank you 🙂

    What is the dissimilitude among a collocate and an illustration of the collocate? What are the benefits of encapsulation? What is the dissimilitude among the Individual construction and the Individual collocate adown? struct Individual { string indicate: int seniority: }: collocate Individual { string indicate: int seniority: };

    Expert Tally

     

    1) Question : What is the dissimilitude among a collocate and an illustration of the collocate?

    ANSWER :

    1. An Illustration of a collocate is designated an Aim and an aim is constituted from a collocate . Sothat now we enjoy to apprehend the dissimilitude among collocate and the aim.
    2. A Collocate is a fidelity of how an Aim has to be instanciated and An aim is an Illustration of a Collocate(Characteristic and proceeding of a collocate is an aim).
    3. Class describes the unconcealed behaviour of aims where as instance is the predicament of collocate at a feature period i.e.,retreat period
    4. Collocate is a store of facts constituent and constituent functions and also it is a manifestationr specify facts emblem. Each illustration of collocate contains every constituents(variables and functions) apparent in the class.

    EX:

    class A{

    int i; //Illustration Variable

    String s; //Illustration Variable

    }

    2) What are the benifits of encapsulation ?

    ANSWER :

    Encapsulation is wrapping the facts and orders together as a uncombined individual.

    Encapsulation is specifyd as follows:

    • Declare the variables of a collocate as private emblem that resources they can be bearinged solely by other constituents of the collocate, and referpotent by any other dissect of your program. Ex : peculiar int x; peculiar char c;
    • Constitute open collocate to object the variables values.
    • Encapsulation is the technique of constitute the scenes in a peculiar collocate and providing bearing to the scenes via open orders.
    • If a scene is apparent peculiar, it canreferpotent be bearinged by anyone without the collocate, thereby shirking the scenes among the collocate.
    3) Question : what is the dissimilitude among the individual construction and the individual collocate?
    

    ANSWER :

    By delinquency, a class has every constituents are of private emblem and a struct is a class where constituents are of open emblem.

    struct Individual
    {
    string indicate;
    int seniority;
    };

    Here struct is a keyword of emblem open as defalut as we already examine.

    Here brace variables designated indicate of emblem string and seniority of emblem integer. These twain are potent to manifestation in any of order.

    struct Individual {

    string indicate;

    int seniority; // indicate and seniority are of open

    };

    int ocean()

    {

    Individual p;

    p.seniority = 20; // works grand becamanifestation seniority is open

    return 0;

    }

    Where as string and indicate variables are Peculiar emblem in collocate.

    collocate Individual {

    string indicate;

    int seniority; // indicate and seniority are of peculiar

    };

    int ocean()

    {

    Individual p;

    p.seniority = 20; // compiler hallucination becamanifestation seniority is peculiar

    return 0;

    }