mercredi 6 septembre 2017

Address unknown type?

my error is that the compiler is saying address is not a member of persontype type specifier my driver is array of 6 personTypes the data from the file is being read in i created adresss of type adresstype so that the data members can have access to the datamembers of adresstype and the data gets filled in correctly how do i fix my error?

#include <iostream>
#include <fstream>
#include "personType.h"
#include <string>
using namespace std;
int main()
{
    personType members[6];
    string x, i1, i2;
    ifstream myfile;
    myfile.open("infile.txt");
    for( int i = 0; i < 6; i++)
    {
        myfile >> members[i].lastName  >> members[i].firstName >> members[i].personNum >> 
            members[i].personID >> members[i].address.streetAddressNum >>
 members[i].address.streetName >> members[i].address.streetType >> members[i].address.city >>             members[i].address.stateInitials >>  members[i].address.zipCode >> members [i].gender;
        myfile>> i1 >> i2; 
        members[i].setInterest1(i1);
        members[i].setInterest2(i2);
        members[i].printPerson();
    }    
    myfile.close();
    system("pause");    
    return 0;
#include <iostream>
#include <string>
using namespace std;
class personType
{
public:
    personType();
    string firstName;
    string lastName;
    int personNum;
    char gender;
    int personID;
    addressType address;
    void setInterest1(string interest1);//mutator
    void setInterest2(string interest2);
    void printPerson();
    string  GetInterest1() const;    // Accessor
    string  GetInterest2() const;
private:
    string SetInterest1;
    string SetInterest2;
};
class addressType {
public:
    addressType();
    string streetAddressNum, streetName, streetType, city, stateInitials;
    int zipCode;
};

Aucun commentaire:

Enregistrer un commentaire