I have a struct
Inside myStructure.h
struct myStructure
{
int myInteger;
double myDoublesArray[4];
char myCharArray[79];
};
Inside myClass.h
#include "myStructure.h"
class myClass
{
private:
myStructure myStruct[4]
private:
Prog1Class();
~Prog1Class();
void setMyStructData();
};
Inside main.cpp
#include<iostream>
#include <string>
#include "myClass.h"
#include "myStructure.h"
using namespace std;
void myClass::setMyStructData()
{
for(int i = 0; i < 5 ; i++)
{
cout << "Please enter an integer: " << endl;
cin >> myStruct[i].myInteger;
for(int j = 0; j< 5; j++)
{
cout << "Please enter a double: ";
cin >> myStruct[i].myDoublesArray[j];
}
cout << endl << "Please enter a string: ";
cin.ignore(256, '\n');
cin.getline(myStruct[i].myCharArray, 79, '\n');
}
}
int main(void)
{
setStructData();
cin.get()
}
The errors i'm getting are " 'myStructure' : 'struct' type redefinition " , and " left of '.myInteger' must have class/struct/union "
I'm sure it's some simple mistake I've made with the structure, but I've looked around and everything seems to be correct to my noob eyes. Thanks!
And this isn't homework. I'm just trying to get back into programming, and understanding how some different things work, and I'm doing old assignments from other schools. Thanks.
Prog1Struct.h, should that bemyStructure.h?