nested structure
Mar 31, 2009 at 6:30am UTC
I have studied structures and a little confused about nested structure.
I will be very thankful ,If anyone fix this program and give me more examples of nested structures .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#include<iostream>
using namespace std;
struct masih {
string title;
int year;
};
struct tukhi {
string name;
string email;
masih favorite_movie;
} charlie, maria;
tukhi * pfriends;
*pfriends= &charlie;
int main()
{
charlie.favorite_movie.year=7;
cout <<charlie.favorite_movie.year;
return 0;
}
Last edited on Mar 31, 2009 at 6:31am UTC
Mar 31, 2009 at 7:00am UTC
pfriends is global variable.
Just move line 17 into main().
Topic archived. No new replies allowed.