Hello there. I was asked to design a program using a dynamic array of structures. I've done it before and worked fine. But this time around I can't figure out what I'm doing wrong.
Here is the code.
header.h
#ifndef HEADER_H
#define HEADER_H
struct Sparks
{
char name[20];
int number;
};
#endif // HEADER_H
strucutre.cpp
usingnamespace std;
main int()
{
Sparks *psparks = new Sparks[3];
psparks =
{
{"Special", 73},
{"Timing", 30},
{"Speeding", 25}
};
for (int i = 0; i < 3; i++)
cout << psparks[i] << endl;
return 0;
};
Here is error message I get every time I run this program.
C:\Users\Misbah\Desktop\Classes\chapter 8\main.cpp|157|error: no match for 'operator=' in '*(overing + 72u) = {"Misbahu", 73}........
I even try doing initializing the struct members upon declaring the dynamic array, but it still fail.
I also place the struct in the structure.cpp, place it above the code, but still it failed.
Please someone out there should point my mistake out.