Access to nested structures

I have a nested structure which I am unable to access. Do I need to create an instance of the structure type tDate? I have no idea how to achieve that.
before Any ideas?

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>

struct tPerson
{
  struct tDate
  {
   int day;
   int month;
   int year;
  };

  char name[20];
  char adresse[50];
  char telefon[20];

  int somethingelse;

};

int main(void)
{
  //I am unable to access date this way
  //tDate date = { day:10, month: 11, year: 1999};
  tPerson person = {
    name:"Firstname Lastname",
    adresse:"Mainstreet 100, 1234 MyTown",
    telefon:"0012345678"
  };


  return 0;
}
Last edited on
tPerson::tDate date;
Or
1
2
3
4
5
6
struct tDate
  {
   int day;
   int month;
   int year;
  }date;

May make it easier, though I would add a ctor to initialize.
Last edited on
Thanks to all for replies and the clarification.

Now i remember having read somewhere that structures are classes with public access classifiers. This way you can access the internal parts of structure just like public elements of a class with class scope identifiers.

I have some code which makes use of this technique of nested structures very intensively.


cheers,
Topic archived. No new replies allowed.