Computer Science, asked by AngelD1009, 1 year ago

Write the function header and body of display() which takes single generic parameter and prints it's value in c++

Answers

Answered by CoolBro003
0

Le me give you one example: [Array of Objects]


#include<iostream.h>

#include<conio.h>

Class Product

{

  int ProductNo, ProductCost;

  char Phone[20];

   Public:

         void getdata();

         void display();

    };

void Product :: getdata()

{

 cout<<"Enter ProductNo, Phone and ProductCost \n";

    cin>>ProductNo>>Phone>>ProductCost;

 }

void Product :: display()

{

cout<<ProductNo<<"\t"<<Phone<<"\t"<<ProductCost<<endl;

 }

void main()

{

Product[3];

int i;

clrscr();

for(i=0; i<3; i++)

  P[i].getdata();

for(i=0; i<3; i++) # done by Coolbro

  P[i].display();

getch();

}


If you have Some more questions, then contact me at:

  Email: [email protected]

   Youtube: shorturl.at/mnB57

Similar questions