【发布时间】:2020-03-08 16:59:14
【问题描述】:
所以我的编译器抱怨我的 destination.travelTime 有 3 个参数,虽然它应该有 3 个参数,关于如何解决这个问题的任何建议还是我错了? 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;
}
【问题讨论】:
-
TL;DR:做
tourType destination { "Nottingham", 130, {3, 15.0, 0} };
标签: c++ visual-c++ struct