Pointer help please...

I'm dealing with an array of pointer structures and I'm very new to pointers. But my issue is specifically with void add(), since that's the only one I've got so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
using namespace std;

struct Fraction
{
	int num;
	int den;
};

void add(Fraction* [], char, int&);
void deleteall (Fraction*, int&);
int main()
{
	Fraction* fracptrs[20] = {0};
	int size = 0;
	char slash = '/';


         do{
		cout<<"Choose an option: \n"
			<<"\t1. Add new fraction\n"
			<<"\t2. Edit fraction\n"
			<<"\t3. Delete fraction\n"
			<<"\t4. Find fraction\n"
			<<"\t5. Display all fractions\n"
			<<"\t6. Show sum of all fractions\n"
			<<"\t7. Delete all fractions\n"
			<<"\t8. Quit\n"
			<<"Your option is... ";
		cin>> choice;

		if(choice == 1)
		{
			add(fracptrs, slash, size);
		}

	}while(choice != 8);

	cout << '\n';
	system ("pause");
	return 0;
}

void add(Fraction* fracptrs[], char slash, int& size)
{
	fracptrs[size] = new Fraction;
	cout<<"Enter a fraction: ";
	cin>> fracptrs[size] -> num >> slash >> fracptrs[size] -> den;

	cout<<"\nYou added the fraction: " << fracptrs[size] << '\n';

	size++;
}


I know I haven't written all of the code yet. Anyways, my main issue is the second cout statement in the void add() function. It seems to display what I think is the address of the array. How can I make it so that it displays the actual element??? Perhaps, my whole code is wrong...please shed me some light. Thanks :)
It seems to display what I think is the address of the array
No, it's the value of the pointer of new Fraction

The output is equivalent to the input:
cout<<"\nYou added the fraction: " << fracptrs[size] -> num << slash << fracptrs[size] -> den << '\n';
Topic archived. No new replies allowed.