Q:

Using our first version of Sales_data from § 2.6.1 (p. 72), explain the following initialization. Identify and fix any problems

0

Using our first version of Sales_data from § 2.6.1 (p. 72), explain the following initialization. Identify and fix any problems.

Sales_data item = {"978-0590353403", 25, 15.99};

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <string>

struct Sales_data {
  std::string bookNo;
  unsigned units_sold; //= 0;
  double revenue; //= 0.0;
  // Error: Cannot provide in-class initializer for an aggregate class
  // (since C++11) (until C++14)
};

int main() {
  Sales_data item = {"978-0590353403", 25, 15.99};

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now