struct
Please, who sees where there is an error?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <iostream>
#include<string>
using namespace std;
struct car{
int weight;
string color;
};
int main()
{
car car1={100, "red"};
car car2={200, "blue"};
car car3={300, "green"};
int * pc1;
pc1=&car1;
/*cout<<pc1<<endl;
cout<<&pc1<<endl;
cout<<*pc1<<endl<<endl;
cout<<(*pc1).weight<<" "<<pc1->color<<endl;
cout<<(*pc2).weight<<" "<<pc2->color<<endl;
cout<<(*pc3).weight<<" "<<pc3->color<<endl;*/
return 0;
}
|
Just does not want to compile, problem is in line:
Many thanks!!!
car1 is of type car.
pc1 is a pointer to something of type int.
Try car * pc1;
Oh, shit, yes!!!
Too many data to see the sheer theory!!!
Many thanks!!!
Topic archived. No new replies allowed.