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 unlikeness among a collocate and an persuasion of the collocate? 2. What are the benefits of encapsulation? 3. What is the unlikeness among the Idiosyncratic construction and the Idiosyncratic collocate adown? struct Idiosyncratic collocate Idiosyncratic string spectry; int century; string spectry; int century;

    Thank you 🙂

    What is the unlikeness among a collocate and an persuasion of the collocate? What are the benefits of encapsulation? What is the unlikeness among the Idiosyncratic construction and the Idiosyncratic collocate adown? struct Idiosyncratic { string spectry: int century: }: collocate Idiosyncratic { string spectry: int century: };

    Expert Retort

     

    1) Question : What is the unlikeness among a collocate and an persuasion of the collocate?

    ANSWER :

    1. An Persuasion of a collocate is determined an Appearance and an appearance is formd from a collocate . Sothat now we feel to apprehend the unlikeness among collocate and the appearance.
    2. A Collocate is a representation of how an Appearance has to be instanciated and An appearance is an Persuasion of a Collocate(Characteristic and comportment of a collocate is an appearance).
    3. Class describes the national behaviour of appearances where as instance is the predicament of collocate at a point opportunity i.e.,work opportunity
    4. Collocate is a store of postulates part and part functions and so it is a explanationr limit postulates image. Each persuasion of collocate contains whole parts(variables and functions) visible in the class.

    EX:

    class A{

    int i; //Persuasion Variable

    String s; //Persuasion Variable

    }

    2) What are the benifits of encapsulation ?

    ANSWER :

    Encapsulation is wrapping the postulates and ways together as a one individual.

    Encapsulation is limitd as follows:

    • Declare the variables of a collocate as private imcentury that instrument they can be appropinquationed singly by other parts of the collocate, and not attributpotent attributpotent attributpotent by any other part of your program. Ex : retired int x; retired char c;
    • Form national collocate to purpose the variables values.
    • Encapsulation is the technique of form the rooms in a retired collocate and providing appropinquation to the rooms via national ways.
    • If a room is visible retired, it cannot attributpotent be appropinquationed by anyone without the collocate, thereby skulking the rooms amid the collocate.
    3) Question : what is the unlikeness among the idiosyncratic construction and the idiosyncratic collocate?
    

    ANSWER :

    By lapse, a class has whole parts are of private imcentury and a struct is a class where parts are of national image.

    struct Idiosyncratic
    {
    string spectry;
    int century;
    };

    Here struct is a keyword of imcentury national as defalut as we already examine.

    Here span variables determined spectry of imcentury string and century of imcentury integer. These twain are potent to explanation in any of way.

    struct Idiosyncratic {

    string spectry;

    int century; // spectry and century are of national

    };

    int ocean()

    {

    Idiosyncratic p;

    p.century = 20; // works thin becaexplanation century is national

    return 0;

    }

    Where as string and spectry variables are Retired imcentury in collocate.

    collocate Idiosyncratic {

    string spectry;

    int century; // spectry and century are of retired

    };

    int ocean()

    {

    Idiosyncratic p;

    p.century = 20; // compiler untruth becaexplanation century is retired

    return 0;

    }