check this sol frends
#include<iostream>
using namespace std;
class A
{
    private:
    int a;
    public:
    A(int m)
    {
        a=m;
    }

};
int main()
{
    cout<<"Enter no of objects in array"<<endl;
    int p,n;
    cin>>n;
    cout<<"Enter  value of a for first object of array"<<endl;
    cin>>p;
    static A obj[]={A(p)};
    for(int i=0;i<n;i++)
    {
        cout<<"Enter value of private member"<<endl;
        cin>>p;
        obj[++i]=A(p);

    }
    return 0;


}


On Fri, May 27, 2011 at 8:07 PM, Logic King <[email protected]>wrote:

> @D.N. I Think if you removes default constructor and give only parametrized
> constructor...then it i going to give any error....it should work fine..
>
>
> On Fri, May 27, 2011 at 4:40 AM, Aakash Johari <[email protected]>wrote:
>
>> Provide some default value to the parameterized constructor.
>> *
>> A(int m = 0) {
>>         a = m;
>> } *
>>
>> On Fri, May 27, 2011 at 4:36 AM, D.N.Vishwakarma@IITR 
>> <[email protected]>wrote:
>>
>>> without default constructor what will be solution
>>>
>>> On Wed, May 25, 2011 at 10:56 AM, Aakash Johari 
>>> <[email protected]>wrote:
>>>
>>>> This way you can do:
>>>>
>>>> #include <iostream>
>>>>
>>>> using namespace std;
>>>>
>>>> class A {
>>>>         public:
>>>>                 int a;
>>>>
>>>>                 A(int m) {
>>>>                         a = m;
>>>>                 }
>>>>
>>>>                 A() {
>>>>                 }
>>>> };
>>>>
>>>> int main()
>>>> {
>>>>         int i;
>>>>
>>>>         A *obj[32];
>>>>
>>>>         for ( i = 0; i <= 31; i++ ) {
>>>>                 obj[i] = new A(i);
>>>>         }
>>>>
>>>>         for ( i = 0; i <= 31; i++ ) {
>>>>                 cout << obj[i]->a << endl;
>>>>         }
>>>>
>>>>         return 0;
>>>>
>>>> }
>>>>
>>>> On Tue, May 24, 2011 at 9:38 PM, immanuel kingston <
>>>> [email protected]> wrote:
>>>>
>>>>>
>>>>> http://www.java2s.com/Tutorial/Cpp/0180__Class/Initializeanarrayofobjectsbyreferencingtheconstructordirectly.htm
>>>>>
>>>>>
>>>>> http://www.java2s.com/Tutorial/Cpp/0180__Class/Initializeanarrayofobjectswithoutreferencingtheconstructordirectly.htm
>>>>>
>>>>> Thanks,
>>>>> Immanuel
>>>>>
>>>>>
>>>>>
>>>>> On Wed, May 25, 2011 at 7:34 AM, D.N.Vishwakarma@IITR <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> There is a class A which contains just one parameterized constructor
>>>>>> A(int a). How would you initialize an array of objects of this class.
>>>>>>
>>>>>> --
>>>>>> **With Regards
>>>>>> Deoki Nandan Vishwakarma
>>>>>> IITR MCA
>>>>>> Mathematics Department*
>>>>>> *
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to [email protected].
>>>>>> To unsubscribe from this group, send email to
>>>>>> [email protected].
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> -Aakash Johari
>>>> (IIIT Allahabad)
>>>>
>>>>
>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>> **With Regards
>>> Deoki Nandan Vishwakarma
>>> IITR MCA
>>> Mathematics Department*
>>> *
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> -Aakash Johari
>> (IIIT Allahabad)
>>
>>
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
**With Regards
Deoki Nandan Vishwakarma
IITR MCA
Mathematics Department*
*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to