Hi, i have three classes
1. Rental.H
Code:
/* All my includes */
....
class Driver;
class Rental
{
public:
Rental(Driver& d);
~Rental();
....
....
void CreateNewContract();
....
....
private:
Driver& driver;
};
#endif
2. Driver.H
Code:
/* All my includes */
....
class Driver
{
public:
Driver();
....
void SetAddress(const Address& add);
Address getAddress() const;
....
private:
....
Address address;
....
};
3. Address.H
.....
.....
I then use them in Rental.cpp
Code:
void Rental::ReadNewAddress()
{
/* Declare variables & read data from use */
.....
.....
/* Here' my Problem */
driver.getAddress().SetAddress(fline, sline, sbb, city, cde);
}
As you noticed, address object is a member to driver, i initialize it as you can see above ... But after this line the address object is always empty ... The function SetAddress() works well cause i used Debug to check if all its members ...
Code:
std::string firstLine;
std::string secondLine;
std::string thirdLine;
std::string city;
std::string code;
were set properly ... Is there any other way to do this except driver.getAddress().SetAddress()?