Function overloading + structures

It won't output the void add();

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  #include<iostream>
#include<iomanip>
#include<string>
#include<string>
#include<conio.h>
#include<stdlib.h>
#define a1 100
using namespace std;
int choice;
struct Address{
	struct{
		char fname[a1];
		char lname[a1];
		string address;
		int cnum;
	}input;
};
void newLine();
void line(char, int);
void add();

int main()
{
	Address menu[a1];
	char tryAgain;
	do {
		system("cls");
		system("COLOR D");
		cout << "-------------------Address Book";
		line('-', 19);
		cout << "\n           What would you like to do?\n";
		line('-', 50);
		cout << "                [1] Add Contact \n";
		cout << "                [2] Edit Contact \n";
		cout << "                [3] Delete Contact \n";
		cout << "                [4] View Contacts \n";
		cout << "                [5] Search Address Book \n";
		cout << "                [6] Exit \n";
		line('-', 50);
		cout << "Please enter your choice: ";
		cin >> choice;
		switch (choice){
		case 1:
			void add();
			break;
		case 2:
			/*system("cls");
			cout << "Enter n: ";
			cin >> x;
			p2(x);*/
			break;
		case 3:
			/*system("cls");
			cout << "Enter n: ";
			cin >> x;
			p3(x);*/
			break;
		case 4:
			exit(1);
		default:
			cout << "Invalid choice \n\n";
			break;
		}
		cout << "\nWould you like to try again (Y/N)";
		cin >> tryAgain;
	} while (tryAgain == 'Y' || tryAgain == 'y');

	system("pause>0");
	return 0;
}

void add()
{
	Address menu[a1];
	system("COLOR B");
	cout << "First Name: " << menu[a1].input.fname;
	cout << "Last Name: " << menu[a1].input.lname;
	cout << "Adrress: " << menu[a1].input.address;
	cout << "Contact Number: " << menu[a1].input.cnum;
	system("pause");
}

void newLine()
{
	char s; do{
		cin.get(s);
	} while (s != '\n');
}

void line(char ch, int ctr) 
{
	for (int i = 0; i < ctr; i++) {
		cout << ch;
	}
	cout << endl;
}
You do not call a function like this:
1
2
3
4
switch (choice){
		case 1:
			void add();
			break;


that void should not be there when calling a function.
Last edited on
ohhH!!!!!
though i checked and it still errors so i changed my code entirely and it worked but thanks for the help anyways
no worries. can i ask why you've nested a struct within another one?
idk. i'm completely noob at programming so i don't know what i am doing ahah
Topic archived. No new replies allowed.