class isssue

hello guys
can you help me ? why is this all jacked up?

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
#include<iostream>
#include <string>
#include<cctype>
using namespace std;

class personType
{

public: 
personType();
	
	
personType(string , char,int);
	

void set(string , char, int);
	

void print() const;
	

private :
	string name; 
	char sex;
	int age;


};
	
	
personType();
	{
		name = " ";
		sex = 'M';
		age = -1;
	}
	
personType(string x, char y, int z);
{
		name = x;
		sex = y;
		age = z;
}


void personType::set(string a, char b, int c);
	{
		name = a;
		sex = b;
		age = c;
	}

	
void personType::print() const;
{
		cout << "Name: " << name << endl;
		if(toupper(sex) == ' M')
		cout << "gender : Male" << endl;
		else 
			cout << " Gender : Female " << endl;
		cout << "Age" << age << endl;


}
I didn't tested the whole thing, but you declare every constructor and method twice. Remove the ; in the definitions and add personType with the scope resolution operator or the compiler will not be able to refer to the constructors of the class.

E.g.

1
2
3
4
5
6
7
 
personType();
	{
		name = " ";
		sex = 'M';
		age = -1;
	}


becomes

1
2
3
4
5
6
7
 
personType::personType();
	{
		name = " ";
		sex = 'M';
		age = -1;
	}


Btw, it's a convention to write the class name with both capital letters, PersonType instead of personType, but use what you are comfortable with.
Hi thanks I have solved it .
Topic archived. No new replies allowed.