---
title: "How to create a array of objects in c  ?"  
description: "How to create a array of objects in c  ?"  
author: "Anonymous User"  
published: 2013-06-14  
updated: 2013-06-15  
canonical: https://www.mindstick.com/forum/1108/how-to-create-a-array-of-objects-in-c  
category: "visual c++"  
tags: ["visual c++"]  
reading_time: 1 minute  

---

# How to create a array of objects in c  ?

Hi,\
How to create a [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) of [objects](https://www.mindstick.com/forum/145447/what-are-objects) in [c++](https://www.mindstick.com/blog/745/array-in-c-plus-plus)?\
Thanks in advance.

## Replies

### Reply by AVADHESH PATEL

Hi,\
try this:\

```
class sample{int a;public:void set_a(int n) {a=n;}int get_a( ) {return a}};int main(){sample ob[4];int i;for(i=0;  i<4;  i++) ob[i].set_a(i);for(i=0; i<4; i++) cout<< ob[i].get_a( );cout<<" \n";return 0;}
```


---

Original Source: https://www.mindstick.com/forum/1108/how-to-create-a-array-of-objects-in-c

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
