Structures, C/C++ Programming

Assignment Help:

  A more advanced data type is the structure; here we can define a template as a collection of different variables e.g.
 
  struct birthdate
  {
    int month;
    int day;
    int year;
  };
 
  Here the template birthdate consists of three separate content variables namely month   , day , year .We can access each part of the structure by means of the dot '.' operator i.e. after we have allocated the variable to be used to hold the structure.
 
    struct  birthdate john;
 
We can access all the details i.e.
 
      john.month  = 12;
      john.day = 28;
      john.year = 52;
 
This is identical to using a two dimensional array to hold the values
 
      john[0][0]  could hold month
      john[0][1]  could hold day
      john[1][0]  could hold year

However using a structure template we can use different types in the same structure
   
    struct details
    {
    int month;
    int day;
    int year;
    char * name;
    };
 
It is possible to use structures defined as pointers, if you wish to want to use the actual address.
 
  
    main()
    {
      struct *records 
      {
      int month;
      int day;
      int year;
      char * name;
      };
 
  Here we have a structure assigned to a pointer record. In order to access the content month we use must dereference the pointer and access the element i.e.
 
      (*records).month 
 
This is often replaced with a -> symbol (minus followed by >) i.e.
 
      records -> month.


Related Discussions:- Structures

Flowcharting, how to create a flowchart? can you help me in my assignment a...

how to create a flowchart? can you help me in my assignment about flowcharting ....

Loop, wap to count the numof string present in a word

wap to count the numof string present in a word

Explain the function prototype - computer programming, Explain the Function...

Explain the Function Prototype? The Functions must be declared before they are used, ANSI C provides for the new function declaration syntax called as the function prototype,

Padovan string, A Padovan string P(n) for a natural number n is defined as:...

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concate

External iterator and an internal iterator, What is the difference between ...

What is the difference between an external iterator and an internal iterator? Ans) An internal iterator is executed with member functions of the class that has items to step th

Develop diablo 2 lod 1.13d dupe method for closed battle.net, Develop Diabl...

Develop Diablo 2 LOD 1.13d Dupe Method for Closed Battle.net This hack is for diablo 2 lord of destruction The program must work on all realms, all cores, all ladders (4x rea

How can i present printing for my class fred?, A: Use operator overloading ...

A: Use operator overloading to present a friend left-shift operator, operator #include class Fred { public: friend std::ostream& operator ... private: int i_; // onl

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd