-
problem error c2552
I'm have an error on this program
#include <iostream>
#include <string>
using namespace std;
struct Employee
{
char lastname[50];
char firstname[50];
string ssn;
int month;
int day;
int year;
};
int main()
{
Employee oneEmployee = { "Maxwell", "Houser", "423-23-2342", 3, 23, 1977};
cout << " The first Employee is :"
<< oneEmployee.lastname << " ,"
<< oneEmployee.firstname << " "
<< oneEmployee.ssn << " "
<< oneEmployee.month << "/"
<< oneEmployee.day << "/"
<< oneEmployee.year << endl;
return 0;
}
can anyone help me ...
-
this is a non-aggregate, which (we all know), cannot be initialized with an initializer list :)
to initialize this non-aggregate, go like this:
Code:
Employee oneEmployee;
strcpy(oneEmployee.firstname,"Maxwell");
strcpy(oneEmployee.lastname, "Houser");
oneEmployee.ssn="423-23-2342";
oneEmployee.month=3;
oneEmployee.day=23;
oneEmployee.year=1977;
-
-
yay, this is the first time i answered someones question correctly!
-
I knew it was something simple but i just couldnt pin point it.
I mite have more questions later on tonite.