what is not good in this function?

1
2
3
4
5
6
7
8
9
	void set(int newprice=-1,char newname[]={"NONAME"},int newqty=-1)
		{
			if(price!=-1)
			price=newprice;
			if(strcmp(newname,"NONAME")!=0)
			strcpy(name,newname);
			if(qty!=-1)
			qty=newqty;
		}

in the above code .... what is not a good habit or illegal
i get a warning like this......

[Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
Last edited on
closed account (3qX21hU5)
Your warning means that you don't have c++11 enabled in your compiler. What compiler are you using? Most now days support c++11 but some require you to turn it on.

The compiler is giving you that warning because of this char newname[]={"NONAME"}.

As for bad habits your indentation is kind of wierd in my opinion but that is a personal choice I guess so just keep it consistent (Indent your if statements).
Last edited on
Topic archived. No new replies allowed.