Vote count:
0
Language C++ Here's the complete code:
#include <iostream>
using namespace std;
struct part
{
int model_numb;
int part_numb;
float cost;
};
void main()
{
part part1, part2 = { 2022, 203, 2121.23F };
char dummy;
part1.model_numb = 12345;
part1.part_numb = 203;
part1.cost = 5050.30F;
cout << "******Part1*****" << endl;
cout << "\nModel Numb: " << part1.model_numb
<< "\nPart Numb: " << part1.part_numb
<< "\nCost: " << part1.cost << endl << endl;
cout << "******Part2*****" << endl;
cout << "\nModel Numb: " << part2.model_numb
<< "\nPart Numb: " << part2.part_numb
<< "\nCost: " << part2.cost << endl << endl;
part1 = part2;
cout << " part1 = part2" << endl << endl;
cout << "******Part1*****" << endl;
cout << "\nModel Numb: " << part1.model_numb
<< "\nPart Numb: " << part1.part_numb
<< "\nCost: " << part1.cost << endl << endl;
cout << "******Part2*****" << endl;
cout << "\nModel Numb: " << part2.model_numb
<< "\nPart Numb: " << part2.part_numb
<< "\nCost: " << part2.cost << endl << endl;
cin >> dummy;
}
If I replace the following line:
part part1, part2 = { 2022, 203, 2121.23F };
with these lines:
part part1, part2;
part2 = { 2022, 203, 2121.23F };
the code won't work. It gives me syntax errors ( missing ';' before '{' ) ( missing ';' before '}') and (expected an expression) at those lines. Whyy??? I'm sure I've made no changes to the second program, except for the ones mentioned.
asked 58 secs ago
Aucun commentaire:
Enregistrer un commentaire