Sign in to follow this  
AztecMinion

I need help with my prototype

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this