calling a class function in main but it's declared in it's own cpp


in my class.h i have.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  class AddressBook
{
private:
	string firstName;
	string lastName;
	int streetNum;
	string streetName;
	string city;
	string state;
	int zipCode;

public:
	void setFirstName(string temp);
	void setLastName(string temp);
	void setStreetNum(int tempInt);
	void setStreetName(string temp);
	void setCity(string buff);
	void setState(string buff);
	void setZipCode(int zip);


and in the class.cpp i have

1
2
3
4
5
6
7
8
void AddressBook::setFirstName(string temp) {

	AddrBook[entryCnt].firstName = temp;

	cout << AddrBook[entryCnt].firstName;
	
}



and in main.cpp i have
1
2

setFirstName(temp);



but yet visual studios is flagging the function in main saying "setFirstName identifier not found".


any help would be greatly appreciated.
Last edited on
setFirstName(temp);

You need an object to call the function., like:

1
2
3
AddressBook addresses;

addresses.setFirstName("name");
Topic archived. No new replies allowed.