R
Raghu
Hello all,
Can somebody help me hopw to resolve teh probelm of aggregate initialisation
in c++.
Her eis the piece of code.
#include<stdio.h>
class MyTest
{
public:
DECLARE_AGGREGATABLE (MyTest);
MyTest(float input = 0.0f)
ata(input){}
float Data;
};
struct MyStruct
{
MyTest a;
int b;
};
struct MyStruct test[2] = { {1.2f,1},{2.4f,3}};
int main()
{
printf("%f\n",test[0].a.Data);
return 0;
}
I am getting the compialtion error as follows:
error C2440: 'initializing' : cannot convert from 'const float' to 'struct
MyStruct'
No constructor could take the source type, or constructor overload
resolution was ambiguous.
And when i decalrea str4uct variable as follows:
struct MyStruct test = { 1.2f ,3 };
I am getting the following error:
error C2552: 'test' : non-aggregates cannot be initialized with initializer
list
Is there any option to use initaliser list toassign the UDTS aggregately?
Your help is needed at the earliest.
Thanks in Advance.
Raghu
Can somebody help me hopw to resolve teh probelm of aggregate initialisation
in c++.
Her eis the piece of code.
#include<stdio.h>
class MyTest
{
public:
DECLARE_AGGREGATABLE (MyTest);
MyTest(float input = 0.0f)
float Data;
};
struct MyStruct
{
MyTest a;
int b;
};
struct MyStruct test[2] = { {1.2f,1},{2.4f,3}};
int main()
{
printf("%f\n",test[0].a.Data);
return 0;
}
I am getting the compialtion error as follows:
error C2440: 'initializing' : cannot convert from 'const float' to 'struct
MyStruct'
No constructor could take the source type, or constructor overload
resolution was ambiguous.
And when i decalrea str4uct variable as follows:
struct MyStruct test = { 1.2f ,3 };
I am getting the following error:
error C2552: 'test' : non-aggregates cannot be initialized with initializer
list
Is there any option to use initaliser list toassign the UDTS aggregately?
Your help is needed at the earliest.
Thanks in Advance.
Raghu