Author |
Message |
Claus
Joined: Wed Oct 21, 2009 4:23 pm Posts: 107
Gender: Male
|
To continue Captain Mew's inactive topic.
If anyone needs help, please, feel free to ask.
|
Sat Oct 24, 2009 2:41 pm |
|
|
Villerar
Joined: Tue Nov 17, 2009 1:26 am Posts: 648
Gender: Anime Girl
|
I have a question regarding the use of arrays in functions. I have several errors in my program that have to do with arrays in my function heads: My compiler (Dev-C++) however gives me the following error: It would be vital to make the arrays call by reference in many cases. Does anybody know how to solve this error?
_________________Liberal Socialist Mudraking Bastard (Averted, not performing any journalism)
|
Wed Nov 18, 2009 9:30 am |
|
|
SS
Joined: Sat Aug 16, 2008 8:38 am Posts: 6670 Location: Darkest Antartica Country:
Gender: Male
Skype: Thaiberium
Currently Playing: The Game
|
What's with the & in your function?
That and have you read documentation concerning passing an array of undefined sized as an argument to a function? I'm not sure if it can be done or not.
Consider using pointers.
|
Wed Nov 18, 2009 11:39 am |
|
|
Villerar
Joined: Tue Nov 17, 2009 1:26 am Posts: 648
Gender: Anime Girl
|
I have seen sheets using arrays of undefined size in the function header. My book (Absolute C++) also shows arrays with no defined size.
I used the & because it needs to be call by reference, the function is supposed to alter the values of the array. I am fairly sure that is where the source of the problem lies, but I do not know how to make it call by reference otherwise (the book does not address call by reference arrays).
_________________Liberal Socialist Mudraking Bastard (Averted, not performing any journalism)
|
Wed Nov 18, 2009 3:32 pm |
|
|
SS
Joined: Sat Aug 16, 2008 8:38 am Posts: 6670 Location: Darkest Antartica Country:
Gender: Male
Skype: Thaiberium
Currently Playing: The Game
|
Wait. Are you using pointers by any chance?
|
Thu Nov 19, 2009 12:30 am |
|
|
Villerar
Joined: Tue Nov 17, 2009 1:26 am Posts: 648
Gender: Anime Girl
|
I am not in this part of the program, but I don't think I am supposed to use them there.
I've just found that it is impossible to use an array of references, though.
EDIT: Okay, I think sorting the arrays out will be fine. However, I have another question:
I would like to use a member function in a non-member function, but I can't get it to work.
_________________Liberal Socialist Mudraking Bastard (Averted, not performing any journalism)
|
Thu Nov 19, 2009 2:10 am |
|
|
SS
Joined: Sat Aug 16, 2008 8:38 am Posts: 6670 Location: Darkest Antartica Country:
Gender: Male
Skype: Thaiberium
Currently Playing: The Game
|
I'm no longer any good on C++, can you just show me the code?
|
Thu Nov 19, 2009 12:11 pm |
|
|
Villerar
Joined: Tue Nov 17, 2009 1:26 am Posts: 648
Gender: Anime Girl
|
I got it to work, here is how it works:
_________________Liberal Socialist Mudraking Bastard (Averted, not performing any journalism)
Last edited by Villerar on Sat Nov 21, 2009 1:32 pm, edited 1 time in total.
|
Thu Nov 19, 2009 11:48 pm |
|
|
SS
Joined: Sat Aug 16, 2008 8:38 am Posts: 6670 Location: Darkest Antartica Country:
Gender: Male
Skype: Thaiberium
Currently Playing: The Game
|
I never tried object oriented programming in C++, so I can only guess that the function monkey returns a class monkey. Or would that be a constructor using C++?
|
Fri Nov 20, 2009 11:19 am |
|
|
Villerar
Joined: Tue Nov 17, 2009 1:26 am Posts: 648
Gender: Anime Girl
|
The function monkey provides a default frame for non-member functions to call member functions of a specific class.
To be honest, I do not know the difference amongst class, struc and constructor.
_________________Liberal Socialist Mudraking Bastard (Averted, not performing any journalism)
|
Sat Nov 21, 2009 1:35 pm |
|
|
SS
Joined: Sat Aug 16, 2008 8:38 am Posts: 6670 Location: Darkest Antartica Country:
Gender: Male
Skype: Thaiberium
Currently Playing: The Game
|
Above is a simple class from Java. What I mean by constructor is the function that creates an object of the class it belongs to.
|
Sun Nov 22, 2009 3:05 am |
|
|
Villerar
Joined: Tue Nov 17, 2009 1:26 am Posts: 648
Gender: Anime Girl
|
In that case, monkey would be a constructor of the class monkey, yes.
_________________Liberal Socialist Mudraking Bastard (Averted, not performing any journalism)
|
Sun Nov 22, 2009 9:32 am |
|
|
Claus
Joined: Wed Oct 21, 2009 4:23 pm Posts: 107
Gender: Male
|
Constructors are used when you initiate a class. ex. Build, Compiled successfully with VS2008 examine yourself EDIT: Never seen the question get answered, but this is more of a C, C++ version
|
Fri Nov 27, 2009 6:42 pm |
|
|
SS
Joined: Sat Aug 16, 2008 8:38 am Posts: 6670 Location: Darkest Antartica Country:
Gender: Male
Skype: Thaiberium
Currently Playing: The Game
|
|
Sat Nov 28, 2009 3:21 am |
|
|
Claus
Joined: Wed Oct 21, 2009 4:23 pm Posts: 107
Gender: Male
|
eh, Java is a good language, especially if you want to start making games. But it feels more, limited to me. It looks too much like C#, and I just don't understand it. When I was learning Java, I remember for a window, you use JFrame. But for menu's, you have to create, like, 3 different classes :/ I just couldn't understand it.
|
Sat Nov 28, 2009 8:10 am |
|
|