TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Wednesday 17 June 2020

Array Of Object In C++| Array Of Object In C++ Example | Array Of Object In C++ Program| Array Of Object In C++ In Hindi

Array Of Object In  C++


Like array of other user-defined datatype's, an array of type class can also be created. The array of type class contains the objects of the class as its individual elements. Thus, an array of a class type is also known as an array of objects. An array of objects is declared in the same way as an array of any built-in data type.

image of Array Of Object In C++

Fig: Array Of Object In C++

Synatx:

Class name object name[size];


Example:

BCA a[2];


Program:

#include<iostream.h>

#include<conio.h>

class BCA

{

char name[30];

int phone no;

public:

void inputdata();

void outputdata();

};

void BCA::inputdata()

{

cout<<”input name “<<endl;

 cin>>name;

cout<<”input phone no”<<endl;

cin>>phone no;

}

void BCA::outputdata()

{

cout<<name<<endl;

cout<<phone no<<endl;

}

void main()

{

BCA a[3];

for(int i=0;i<=2;i++)

a[i].inputdata();

for(int i=0;i<=2;i++)

a[i].outputdata();

getch();

}


Output:

Input name Pramod

Input phone 1234567889

Input name Vansh

Input phone 8934259812

Input name  Sparsh

Input phone 8381833613

 

 

 

 

 

 


No comments:

Post a Comment