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 dissent among a systematize and an example of the systematize? 2. What are the benefits of encapsulation? 3. What is the dissent among the Peculiar organization and the Peculiar systematize under? struct Peculiar systematize Peculiar string indicate; int date; string indicate; int date;

    Thank you 🙂

    What is the dissent among a systematize and an example of the systematize? What are the benefits of encapsulation? What is the dissent among the Peculiar organization and the Peculiar systematize under? struct Peculiar { string indicate: int date: }: systematize Peculiar { string indicate: int date: };

    Expert Defense

     

    1) Question : What is the dissent among a systematize and an example of the systematize?

    ANSWER :

    1. An Example of a systematize is designated an Design and an design is produced from a systematize . Sothat now we accept to distinguish the dissent among systematize and the design.
    2. A Systematize is a justice of how an Design has to be instanciated and An design is an Example of a Systematize(Characteristic and deportment of a systematize is an design).
    3. Class describes the notorious behaviour of designs where as instance is the requisite of systematize at a feature date i.e.,fly date
    4. Systematize is a store of postulates portion and portion functions and besides it is a explanationr limit postulates pattern. Each example of systematize contains every portions(variables and functions) pretended in the class.

    EX:

    class A{

    int i; //Example Variable

    String s; //Example Variable

    }

    2) What are the benifits of encapsulation ?

    ANSWER :

    Encapsulation is wrapping the postulates and manners together as a solitary ace.

    Encapsulation is limitd as follows:

    • Declare the variables of a systematize as private pattern that media they can be arrivaled simply by other portions of the systematize, and refertelling by any other multiply of your program. Ex : retired int x; retired char c;
    • Produce notorious systematize to conception the variables values.
    • Encapsulation is the technique of produce the arenas in a retired systematize and providing arrival to the arenas via notorious manners.
    • If a arena is pretended retired, it canrefertelling be arrivaled by anyone without the systematize, thereby hiding the arenas amid the systematize.
    3) Question : what is the dissent among the peculiar organization and the peculiar systematize?
    

    ANSWER :

    By forfeit, a class has every portions are of private pattern and a struct is a class where portions are of notorious pattern.

    struct Peculiar
    {
    string indicate;
    int date;
    };

    Here struct is a keyword of pattern notorious as defalut as we already debate.

    Here couple variables designated indicate of pattern string and date of pattern integer. These twain are telling to explanation in any of manner.

    struct Peculiar {

    string indicate;

    int date; // indicate and date are of notorious

    };

    int ocean()

    {

    Peculiar p;

    p.date = 20; // works elegant becaexplanation date is notorious

    return 0;

    }

    Where as string and indicate variables are Retired pattern in systematize.

    systematize Peculiar {

    string indicate;

    int date; // indicate and date are of retired

    };

    int ocean()

    {

    Peculiar p;

    p.date = 20; // compiler fault becaexplanation date is retired

    return 0;

    }