Answer to Question #293574 in C++ for Ianidy

Question #293574

Write a C++ program using a Class function that enables the storing of the following elements in an array as shown: (4 Marks)



-name



- houseno



- street



- city




1
Expert's answer
2022-02-03T12:39:48-0500
#include <iostream>


class StoreAddresses
{


    
public:
    class PersonAddress
    {


        std::string name;
        std::string street;
        std::string city;
        int house_number;


    public:
        PersonAddress() {}
        PersonAddress(std::string& str, std::string& name, std::string& cit, int number)
        {
            this->name = name;
            this->house_number = number;
            this->street = str;
            this->city = cit;
        }
    };


    void fill_Addresses(PersonAddress p1, PersonAddress p2, PersonAddress p3, PersonAddress p4)
    {
        addresses[0] = p1;
        addresses[1] = p2;
        addresses[2] = p3;
        addresses[3] = p4;
    }


private:
    PersonAddress addresses[4];


};



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog