• Create Account

### #Actualreaperrar

Posted 13 January 2013 - 02:06 AM

class MyClass
{
public:
MyClass(int i) : m_i(i);
~MyClass();

private:
int m_i;
}

int main()
{
const unsigned int uiArraySize = 1000;
int iInitializeValue = 5;

MyClass oClass[uiArraySize] = {iInitializeValue, iInitializeValue, iInitializeValue...};

return 0;
}

If I want all instances of the class to intialize with value "iInitializeValue" is there some automatic way this can be done instead of copy paste 1000 times xD?

EDIT: ...Without using anything other than syntax? I don't want to be forced to use something in std::

EDIT: Also, I assume acheiving the same thing is out of the question with the new operator when creating an array, though it would then seem more appropriate to use the std::vector.... unless the object provided to be copied from is non-copyable. /sigh

### #3reaperrar

Posted 13 January 2013 - 01:28 AM

class MyClass
{
public:
MyClass(int i) : m_i(i);
~MyClass();

private:
int m_i;
}

int main()
{
const unsigned int uiArraySize = 1000;
int iInitializeValue = 5;

MyClass oClass[uiArraySize] = {iInitializeValue, iInitializeValue, iInitializeValue...};

return 0;
}

If I want all instances of the class to intialize with value "iInitializeValue" is there some automatic way this can be done instead of copy paste 1000 times xD?

EDIT: ...Without using anything other than syntax? I don't want to be forced to use something in std:: if that is indeed possible.

EDIT: Also, I assume acheiving the same thing is out of the question with the new operator when creating an array ><

### #2reaperrar

Posted 13 January 2013 - 01:12 AM

class MyClass
{
public:
MyClass(int i) : m_i(i);
~MyClass();

private:
int m_i;
}

int main()
{
const unsigned int uiArraySize = 1000;
int iInitializeValue = 5;

MyClass oClass[uiArraySize] = {iInitializeValue, iInitializeValue, iInitializeValue...};

return 0;
}

If I want all instances of the class to intialize with value "iInitializeValue" is there some automatic way this can be done instead of copy paste 1000 times xD?

EDIT: ...Without using anything other than syntax? I don't want to be forced to use something in std:: if that is indeed possible.

### #1reaperrar

Posted 13 January 2013 - 01:11 AM

class MyClass
{
public:
MyClass(int i) : m_i(i);
~MyClass();

private:
int m_i;
}

int main()
{
const unsigned int uiArraySize = 1000;
int iInitializeValue = 5;

MyClass oClass[uiArraySize] = {iInitializeValue, iInitializeValue, iInitializeValue...};

return 0;
}

If I want all instances of the class to intialize with value "iInitializeValue" is there some automatic way this can be done instead of copy paste 1000 times xD;

PARTNERS