check this sol frends
#include
using namespace std;
class A
{
private:
int a;
public:
A(int m)
{
a=m;
}
};
int main()
{
cout<<"Enter no of objects in array"<>n;
cout<<"Enter value of a for first object of array"<>p;
static A obj[]={A(p)};
for(int i=
@D.N. I Think if you removes default constructor and give only parametrized
constructor...then it i going to give any errorit should work fine..
On Fri, May 27, 2011 at 4:40 AM, Aakash Johari wrote:
> Provide some default value to the parameterized constructor.
> *
> A(int m = 0) {
>
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 wrote:
> without default constructor what will be solution
>
> On Wed, May 25, 2011 at 10:56 AM, Aakash Johari wrote:
>
>> This way you can do:
>>
without default constructor what will be solution
On Wed, May 25, 2011 at 10:56 AM, Aakash Johari wrote:
> This way you can do:
>
> #include
>
> using namespace std;
>
> class A {
> public:
> int a;
>
> A(int m) {
> a = m;
>
This way you can do:
#include
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
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.Vishwakarm
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