|
-
November 8th, 2011, 02:08 AM
#1
Array of objects
hi all,
I do know how the array of objects work, as an example here it is:
Code:
Stock *s1=new Stock[2];
char n[29];
int num;
double val;
cout<<"Enter name :";
cin>>n;
cout<<"Enter shares :";
cin>>num;
cout<<"Enter share value :";
cin>>val;
s1[0].setName(n);
s1[0].setShare(num);
s1[0].setShareVal(val);
s1[0].show();
cout<<"Enter name :";
cin>>n;
cout<<"Enter shares :";
cin>>num;
cout<<"Enter share value :";
cin>>val;
s1[1].setName(n);
s1[1].setShare(num);
s1[1].setShareVal(val);
s1[1].show();
delete[] s1;
but i'm still confused about it, how i can do if Stock class has one more class object. like this:
Code:
class Stock
{
public:
Date date;
//some code
};
then how do i create array of objects, including date objects and Stock objects. Please guide me through this.. would be appreciated..
thanks all,
Last edited by Aashi; November 8th, 2011 at 02:23 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|