Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I think the forum is a great idea, especially for those of us in consulting engineering. Keep up the good work!..."

Geography

Where in the world do Tek-Tips members come from?
xwb (Programmer)
2 Jan 08 4:33
Here's a strange one that got me foxed for a while - only happens on VC6.  OK on VC2003 and gcc.  I don't really know whether it is legal to initialize a class as POD or not.

CODE

class Legal
{
public:
    int tom;
    int dick;
    int harry;

private:
    void DoSomething ();
};

Legal ll = { 1, 2, 3 };

int main ()
{
    return 0;
}
Comes up with error C2552: 'll' : non-aggregates cannot be initialized with initializer list
To fix it, comment out private.
uolj (Programmer)
2 Jan 08 17:58
It is legal to initialize a class (or struct) as a POD as long as the class has:
  • No user-declared constructors
  • No private or protected non-static data members
  • No base classes
  • No virtual functions
I'm guessing that's a bug in VC++ 6.0 that considers the private member function to conflict with the second part in the list. The correct interpretation appears to be that only data members (members that can hold an actual value) are subject to that restriction, not member functions.

So your code should be legal according to the standard. Note that it also compiles with Comeau online.
xwb (Programmer)
2 Jan 08 18:31
Thanks for the confirmation.

I'd like the client to move to a more up to date compiler so we can at least drop the pragma warning(disable:4768) and have a better IDE but they're set on VC6 SP5 (note even SP6!) so we have to live with bugettes like these for the next 3 years.  So much for state-of-the-art technology companies!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close