A question before everything else: does your code get compiled? Because I tried copying it and MinGW won't do it
error: 'record' was not declared in this scope
|
This refers to the line right below "else if(menuChoice == 2)"
Everything that follows is under the assumption that you fixed this problem
is there any way to check if records are being stored into the array?
|
1 2
|
for(int i = 0; i < record; ++i)
cout << arrayABC[i].name << endl;
|
This will print every value you gave as a name for all the elements you have created
is there any solutions that I can store/access the information into the array properly and able to access it any where?
|
I'll assume that by "anywhere" you mean anywhere within Test2()
Just define all the variables at the start of the function (by the way, this will fix the problem thrown by the compiler)
As of now you defined the variables inside the if block, so, just like for functions, they belong to the scope of the block and you can't use them outside of it
If you define them outside they'll still exist when you exit the if block (you just changed their value in that) so you'll be able to use them in other parts of the function
and when i choose menu 2, to print out the records of name, record is 0 there. so I am assuming, when choosing menu 2, i cannot access the arrays of data stored in menu 1.
|
I'll assume that you have some sort of loop that calls your Test::Test2() multiple times, because if you don't then the program will end before you have the chance of choosing the option 2 after choosing 1
Try fixing the scope of the variables and see if there is still this problem
Also, please use code tags and proper indentation when you write code here