Ask Question
2 June, 10:59

Write a declaration for a class named City, which has the members cityName, a string, and position, a Location structure (declared above). Then define a variable named destination that is an instance of the City structure, as if it were being used in main.

+4
Answers (1)
  1. 2 June, 14:33
    0
    Following are the statements for the above question in c+ + language:-

    class City / /Class definition.

    {

    string cityName; / /String data type for cityName variable.

    Location position; / /Structure Location data type for position variable.

    };

    City destination; / /class city variable destination.

    Explanation:

    The above question asked to declare a class whose name is the city which contains the two variable cityname of type string and position of type Location structure which is defined above. So the above-defined are the statement which does all task. But before the use of it, any user needs to define the location structure otherwise the statement "Location position; " gives the compile-time error. The syntax to define a class and the instances is defined below : -

    Class class_name

    {

    //datatype variable

    }

    class_name instances_name;
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a declaration for a class named City, which has the members cityName, a string, and position, a Location structure (declared above). ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers