Some help on my dating program.

I get 2 errors when I try to compile my program, the errors happen in my implementation file: error C4716: 'DatingInfo::setMaleSex' : must return a value. And error C4716: 'DatingInfo::setFemaleSex' : must return a value

I've tried different things to return a value but I just can't get it. Any help is greatly appreciated.

Header file.
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
#ifndef DATINGINFO_H
#define DATINGINFO_H
#include <iostream>
#include <string>
using namespace std;

class DatingInfo
{
	private:
	   char sexM;
	   char sexF;
	   string name[20];
	   string phoneNum[8];
	   string interests[10];
	   string match[20];

	public:
	   DatingInfo();
	   void appendNode(string);
	   void insertNode(string);
	   void deleteNode(string);

	   char setMaleSex(char M);
	   char setFemaleSex(char F);
	   void setName(string N);
	   void setPhoneNum(string Pnum);
	   void setInterests(string Intrs);
	   void setMatch(string Mat);
	   void printHeading() const;

	   char getMaleSex() const;
	   char getFemaleSex() const;
	   string getName() const;
	   string getPhoneNum() const;
	   string getInterests() const;
	   string getMatch() const;
};
#endif 


Implementation file.
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
#include "DatingInfo.h"

char DatingInfo::setMaleSex(char M)
{
	sexM = M;
}

char DatingInfo::setFemaleSex(char F)
{
	sexF = F;
}

void DatingInfo::setName(string N)
{
	name[20] = N;
}

void DatingInfo::setPhoneNum(string Pnum)
{
	phoneNum[8] = Pnum;
}

void DatingInfo::setInterests(string Intrs)
{
	for (int i = 10; i < 10; i++)
	{
		interests[i] = Intrs;
	}
}

void DatingInfo::setMatch(string Mat)
{
	match[20] = Mat;
}

void DatingInfo::printHeading() const
{
    cout << "****************************************************" << endl;
    cout << "*                                                  *" << endl;
    cout << "*        Syracuse Online Dating Service		*" << endl;
    cout << "*                                                  *" << endl;
    cout << "****************************************************" << "\n\n\n";
	
	cout << "*** Initial Client Data ***" << "\n\n";

	cout << " Sex            Phone		      Name "		 << endl;
        cout << " ---      -------------------      ------------------ " << endl;
}

char DatingInfo::getMaleSex() const
{
	return sexM;
}

char DatingInfo::getFemaleSex() const
{
	return sexF;
}

string DatingInfo::getName() const
{
	return name[20];
}

string DatingInfo::getPhoneNum() const
{
	return phoneNum[8];
}

string DatingInfo::getInterests() const
{
	return interests[20];
}

string DatingInfo::getMatch() const
{
	return match[20];
}
Last edited on
You said in your implementation:
1
2
3
4
5
6
7
8
9
char DatingInfo::setMaleSex(char M)
{
	sexM = M;
}

char DatingInfo::setFemaleSex(char F)
{
	sexF = F;
}

This won't work. You told the compiler you were going to return a char, but you didn't return anything. That is what it is complaining about. However, a setX method generally doesn't return anything. Maybe you should change the return type to void, and make sure you do the same thing to those declarations in the header file.
I'll try that.
Hm..now I get LNK2019 error. :/

Update: Default constructor was the cause. All good now, thanks Booradley60, appreciate the help.
Last edited on
Did you change the signatures in your header file as well? Did you rebuild everything? How are you calling setMaleSex and setFemaleSex in other code?

EDIT: np :)
Last edited on
I did. I haven't really gotten/started far in my main file yet, all I have is this for the time being:

1
2
3
4
5
int main(void)
{
    DatingInfo info;  // Create info object
    char choice;
}


I'll be using the info data object to be setting and calling the functions.
Topic archived. No new replies allowed.