I'm a c++ student and this is my first post here.
I have an array containing Member objects (which will be dynamic in the future). I'm trying to pass the array into a function, getLogin in my case.
I think I have some of the syntax wrong, I'm still struggling to understand dynamic arrays and correct syntax for pointers in different situations. Visual Studio is showing an error with myMembers, where it is written as a parameter for getLogin.
#include <iostream>
#include <string>
#include "Member.h"
using namespace std;
int getLogin( const int, Member[] );
int main(){
int numAccounts = 0;
int accCapacity = 5;
int currentAcc = 0;
Member member[5];
currentAcc = getLogin( numAccounts, member );
return 0;
}
int getLogin( const int lastAcc, Member[] myMember ){
int accNum;
cout << "account number:" << endl;
cin >> accNum;
if( accNum > 0 && accNum <= lastAcc ){
myMember[accNum].setLoggedIn( true );
}
else{
accNum = 0;
}
return accNum;
}
(p.s. What I really want is a pointer to the array, because I don't want a copy of the entire array to be created. However, I believe that using the array name is actually like using a pointer to the first element. So I think I don't need to worry about that.)