Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,005 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,360 people online right now. Registration is fast and FREE... Join Now!




Classes and Arrays

 
Reply to this topicStart new topic

Classes and Arrays

olams
18 Jan, 2008 - 01:53 PM
Post #1

New D.I.C Head
*

Joined: 13 Apr, 2007
Posts: 22


My Contributions
Hi,
I have a question to ask. this may be a stupid question but i don't know the answer so here it goes.

can arrays be passed as parameters to a member functions of classes?

ex.
void nameofclass::functionname(int p[], int q[], s)

is the above possible in c++?

This post has been edited by olams: 18 Jan, 2008 - 01:53 PM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Classes And Arrays
18 Jan, 2008 - 02:28 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,184



Thanked: 210 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
You most certainly can pass arrays, just like you have it there.

CODE

// Declare an array
int myarray[100];

// Pass it to a function
blahblah(myarray,100);


// function to accept parameter
void blahblah(int theArray[], int size) {
     // Do stuff
}


Enjoy! icon_up.gif

This post has been edited by Martyr2: 18 Jan, 2008 - 02:29 PM
User is online!Profile CardPM
+Quote Post

olams
RE: Classes And Arrays
18 Jan, 2008 - 03:21 PM
Post #3

New D.I.C Head
*

Joined: 13 Apr, 2007
Posts: 22


My Contributions
thanks.

QUOTE(Martyr2 @ 18 Jan, 2008 - 03:28 PM) *

You most certainly can pass arrays, just like you have it there.

CODE

// Declare an array
int myarray[100];

// Pass it to a function
blahblah(myarray,100);


// function to accept parameter
void blahblah(int theArray[], int size) {
     // Do stuff
}


Enjoy! icon_up.gif


User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 12:38PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month