C++- myStructTemplate1

Objectives :

  • struct template
  • template and overloading function ( handling different parameter-data type with type-named class "VariousType").
    • string str1 = " manager";
      Emp<string> mystr1; mystr1.vt = str1;mystr1.getemp(&mystr1.vt);
      // display double data type
      Emp<double> myd1;myd1.vt = 6500.45;myd1.getemp(&myd1.vt);
      //display integer data type
      Emp<int> ptr1 ;ptr1.vt = 1500; ptr1.getemp(&ptr1.vt);
  • Code: myStructTemplate1.txt

Step: 1 Create a project

Step: 2 Create a source file

testStructTemplate1.cpp

Step: 3 Edit Source code

a) Adding header files and creating Struct template

b) Creating struct objects

c) Creating Emp object to process string data type (FYI you must use &operator to access the address of the parameter).

d) Create a parameter to pass double data type

Step: 4 Runtime View

Final runtime view

Step: 5b