struct initializing

Hey guys just a quick question-

when I initialize a struct,

1
2
3
4
struct vList{
	struct varNode * item;
	struct vList * next;
};


like so:

struct vList listofVars = new vList;

Does this make the item and next NULL or do I have to do that myself?

Thanks!
Item and Next will not have values. They will be technically undefined. They each need to be given a value.

You can make a constructor for your struct that would take care of it for you. A struct is exactly the same thing as a class. The only difference is that a class is, by default, private while a struct is, by default, public.

:)
awesome, thanks!
By the way, you shouldn't use new vList, unless if struct vList listofVars is a pointer. If you've got a proper constructor, you can easily ignore any assignments at all.
Topic archived. No new replies allowed.