``toppings[z] = a[z] ;``

If a is declared as a plain int, why are you subscripting it like an array of int? I think you should make the whole thing an array and that'll fix your problem.

``void Pizza::set ( int x , int y , int a[] , int i );``
``````void Pizza::set ( int x , int y , int a[] , int i )
{
type = x ;
size = y ;
for ( int z = 0 ; z < i ; z++ )
toppings[z] = a[z] ;
}``````
``pizza.set ( x , y , a, i ) ;``
Duki commented: great suggetion! +4

awesome!! It's working now!
Now I just need to do some slight modifications and add the computePrice function and I'm done.

thanks everyone!!

I thought you had declared the third parameter as a reference to an array?

``void Pizza::set ( int x , int y , int (&a) , int i )``

i did but then i found out that c++ passes all arrays by reference by default.

i did but then i found out that c++ passes all arrays by reference by default.

You have to be careful here. 'By reference' could mean two things, and only one of them is right. ;) Thef irst by reference is an actual reference in C++ and arrays are not passed by that reference by default. To pass an array by actual reference in C++ you do it like Dave said.

``void Pizza::set ( int x , int y , int (&a) , int i )``

The second by reference is a fake reference that you get by passing a pointer by value and being able to get to the thing that the pointer points to. That's the default for arrays and that's why all of these are the same prototype.

``````void Pizza::set ( int x , int y , int a , int i )
void Pizza::set ( int x , int y , int a[] , int i )
void Pizza::set ( int x , int y , int *a , int i )``````

Woohoo! Finally something I know something about. :D

ah ok. so did i create a pointer?

The answer depends on the current code.

it's the same as post #31.

That's a pointer (see #35).
http://c-faq.com/aryptr/aryptrparam.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.