Classes Error How do i get this program to start

faieq92 (150)
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
	#include <iostream> 
	#include <string>
	#include <math.h> 
	#include <fstream>
	using namespace std;

class Details
{
public:
    Details(); 
    string FirstName;
    string LastName;
    int Age;
    string Email;
    int DoorNumber;
    string RoadName;
    string PostCode;
	
};

void SetInformation(Details &member)
{
    cout << "\nFirst Name: ";
    cin >> member.FirstName;

    cout << "\nLast Name: ";
    cin >> member.LastName;

    cout << "\nAge: ";
    cin >> member.Age;

    cout << "\nEmail: ";
    cin >> member.Email;

    cout << "\nDoor Number: ";
    cin >> member.DoorNumber;

    cout << "\nRoad Name: ";
    cin >> member.RoadName;

    cout << "\nPost Code: ";
    cin >> member.PostCode;
}

int main()
{	int i;
	Details	information[10];	
	cout << "\nWhich Slot would you like to store the informaton in ?(1-10)";
	cin >> i;
	i--;
	SetInformation(information[i]);
return 0;}








Can someone tell me what the problem in this bit of code could be..

1>attemp2.obj : error LNK2019: unresolved external symbol "public: __thiscall Details::Details(void)" (??0Details@@QAE@XZ) referenced in function _main
1>c:\users\faieq\documents\visual studio 2010\Projects\Attempt 2 CHallange 1\Debug\Attempt 2 CHallange 1.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


that's the error im getting
vlad from moscow (3656)
You did not define the default constructor. You only declared it in the class definition but forgot to define it.
vlad from moscow (3656)
If you have a question relative this thread then ask it here. Do not write a PM me. If you want to ask a question personally me you can do that at www.cpp.forum24.ru.

You can define the constructor inside the class definition or outside the class definition.

For example

1
2
3
4
5
6
7
8
9
10
11
12
13
class Details
{
public:
    Details() : Age( 0 ), DoorNumber( 0 ) {} 
    string FirstName;
    string LastName;
    int Age;
    string Email;
    int DoorNumber;
    string RoadName;
    string PostCode;
	
};



Or

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Details
{
public:
    Details(); 
    string FirstName;
    string LastName;
    int Age;
    string Email;
    int DoorNumber;
    string RoadName;
    string PostCode;
	
};

Details::Details() : Age( 0 ), DoorName( 0 ) {}
Last edited on
faieq92 (150)
I understand . That got it working. Also why do I need to do this?

SetInformation(Details &member) the pointer part?
Last edited on
vlad from moscow (3656)
It is not a pointer. It is reference to a class object. Changing it in the function results to changing the original object.
Topic archived. No new replies allowed.