-2

So my compiler is complaining about my destination.travelTime having 3 arguments although it should have 3 arguments, any suggestions on how to fix this or am I in the wrong? TIA

#include <iostream>

using namespace std;


struct timeType
{
    int hr;
    double min;
    int sec;
};

struct tourType
{
    string cityName;
    int distance;
    timeType travelTime;
};


int main()
{
    tourType destination;

    destination.cityName = "Nottingham";
    destination.distance = 130;
    destination.travelTime (3, 15.0, 0);
    return 0;
}

1 Answers1

2

destination.travelTime (3, 15.0, 0); is a function call, not an assignment. You would need to do this instead:

destination.travelTime = timeType{3, 15.0, 0};

Or

destination.travelTime = {3, 15.0, 0};

Depending on your C++ version.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770