Thread: problem error c2552

  1. #1
    Registered User abbynormal87's Avatar
    Join Date
    Apr 2002
    Posts
    17

    Question 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 ...
    The one & only!!

  2. #2
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    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;
    Last edited by Leeman_s; 04-30-2002 at 07:09 PM.

  3. #3
    Registered User abbynormal87's Avatar
    Join Date
    Apr 2002
    Posts
    17

    Smile

    Thanks a million!!

    The one & only!!

  4. #4
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    yay, this is the first time i answered someones question correctly!

  5. #5
    Registered User abbynormal87's Avatar
    Join Date
    Apr 2002
    Posts
    17

    Cool

    I knew it was something simple but i just couldnt pin point it.

    I mite have more questions later on tonite.
    The one & only!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM