Structure - C P P

Theory


  • A structure is a user-defined data type
  • Data members => Variables in the structure
  • Member Function => Function in the structure

Commands


  • Like class can contain Data Members and Member functions, Can declare variables like this
        struct var {
            dataType variable1;
            dataType variable2;
            returnType varF() {
            // statement
            }
        } var1;
    
  • struct var var1 => Declare variable made of structure datatype
  • var1.variable1 = value => Initialize a value
Share: