Jump to content
  • Advertisement
Sign in to follow this  
AztecMinion

I need help with my prototype

This topic is 3978 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok so in a class i have for programming the teacher wrote this on the board but I couldn't couldn't get it to work so, could your guys let me know who the prototypevoid is suppose to look like? #include<iostream> using namespace std; void func1(int*); void func2(int *[]);// fix prototype void main() { int array[10]; cout << sizeof(array) << endl; //it couts the size of the array. which is 40. func1(array); func2(array);// doesn't work } void func1(int *a) { cout << sizeof(a) << endl; } void func2(int (&a)[10]) { cout << sizeof(a) << endl; }

Share this post


Link to post
Share on other sites
Advertisement
We can't really help with homework problems here. If you're having trouble with the material, I'd suggest talking to the instructor, a classmate, or perhaps a TA. You could also take a look at whatever reference you're using for the class (or check any of the good online references on C/C++) and try to figure out for yourself why the second function call doesn't work.

Share this post


Link to post
Share on other sites
Either there is something really really basic you haven't thought about / tried ... or your teacher is a sneaky bastard ... since I don't have a compiler handy I don't know which but I think you just need to stop, think a second and make some attempts at fixing it. When in college, a lot of the point is to think about it, try stuff, then grow to learn why the things you thought we're right or wrong afterward.

Share this post


Link to post
Share on other sites
The code doesn't work intentionally. You have to actually fix a mistake or two in order for it to work. That's the point of your homework. I would suggest rereading the section on Functions in your C++ Book.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!