Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8320781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:46:45+00:00 2026-06-08T22:46:45+00:00

I’d highly appreciate some advice on what might be wrong with my project. I’m

  • 0

I’d highly appreciate some advice on what might be wrong with my project.

I’m trying to compile my project and I get the following errors:

phoneBook.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * phoneBook::lastName" (?lastName@phoneBook@@0PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
phoneBook.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * phoneBook::firstName" (?firstName@phoneBook@@0PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
phoneBook.obj : error LNK2001: unresolved external symbol "private: static int * phoneBook::phone" (?phone@phoneBook@@0PAHA)
phoneBook.obj : error LNK2001: unresolved external symbol "private: static char (* phoneBook::dateOfBirth)[10]" (?dateOfBirth@phoneBook@@0PAY09DA)

Here is the header file:

//phoneBook.h header file
#ifndef PHONEBOOK_H
#define PHONEBOOK_H
#include <string>
using namespace std;

class phoneBook
{
public:
 phoneBook();                                   //default constructor
 phoneBook(string lastN[], string firstN[], 
            int phoneNumber[], char date[][10]);        //overloaded constructor
 void setLastName(string lastN, int idNum);     //sets last name for a given ID number,
                                                //-IDs range from 1 to 50
 void setFirstName(string firstN, int idNum);   //sets first name for a given ID number
 void setPhoneNumber(int phoneNum, int idNum);  //sets the phone number for a given ID number
 void setDate(char dateOB[], int idNum);            //sets the date of birth for a given ID number
 void loadFromFile(char fileName[]);                //loads phone book data from a local file
 int getPhoneNumber(string lastN, string firstN);//returns phone number for particular person
 void getDOB(string lastN, string firstN, char testDOB[]);  //sets date of birth for a particular person to testDOB array
 void printPhone_DOB(string lastN, string firstN);  //print phone number and date of birth
                                                    //-for a given person
 void printNamesForDOB(char month[]);           //print names of people with birthdays on given numeric month
 void saveData();                               //save data back to the local file
private:
 string filename;
 static string lastName[50];
 static string firstName[50];
 static int phone[50];
 static char dateOfBirth[50][10];
};
#endif

Implementation file:

//phoneBook.cpp implementation file
#include "phoneBook.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

//default constructor
phoneBook::phoneBook()
{
//declare variables
int i, j;
string lastName[50];
string firstName[50];
int phone[50];
char dateOfBirth[50][10];

//set variables to zero/null
filename = "";
for(i=0; i<50; i++)
{
    lastName[i] = "";
    firstName[i] = "";
    phone[i] = 0;

    //set date to zero, in format 00/00/0000
    for(j=0; j<10; j++)
    {
        dateOfBirth[i][j] = '0';
        if(j==2 || j==5)
            dateOfBirth[i][j] = '/';
    }
}
}

//overloaded constructor
phoneBook::phoneBook(std::string lastN[], std::string firstN[], int phoneNumber[], char date[][10])
{
//declare variables
int i, j;
string lastName[50];
string firstName[50];
int phone[50];
char dateOfBirth[50][10];

//set variables to zero/null
filename = "";
for(i=0; i<50; i++)
{
    lastName[i] = lastN[i];
    firstName[i] = firstN[i];
    phone[i] = phoneNumber[i];
    for(j=0; j<10; j++)
        dateOfBirth[i][j] = date[i][j];
}
}

//setLastName function, sets the last name for a given ID number
void phoneBook::setLastName(string lastN, int idNum)
{
lastName[idNum-1] = lastN;
}

//setFirstName function, sets the first name for a given ID number
void phoneBook::setFirstName(string firstN, int idNum)
{
firstName[idNum-1] = firstN;
}

//setPhoneNumber function, sets the phone number for a given ID number
void phoneBook::setPhoneNumber(int phoneNum, int idNum)
{
phone[idNum-1] = phoneNum;
}

//setDate function, sets the date of birth for a given ID number
void phoneBook::setDate(char dateOB[], int idNum)
{
//declare variables
int i;

//set DOB
for(i=0; i<10; i++)
    dateOfBirth[idNum][i] = dateOB[i];
}

//loadFromFile function, loads phone book data from a local file
void phoneBook::loadFromFile(char fileName[])
{
/*
**Assuming the following data in the text file:
**LastName FirstName PhoneNumber DateOfBirth
**(repeating 50 times)
*/
//setting local variable
filename = fileName;

//declaring variables
int i, j;

//opening file
ifstream file (filename.c_str());

//getting the data and copying it to local variables
while( file.good() )
{
    for(i=0; i<50; i++)
    {
        file >> lastName[i];
        file >> firstName[i];
        file >> phone[i];
        for(j=0; j<10; j++)
            file >> dateOfBirth[i][j];
        file.ignore(100, '\n');
    }
}

//closing file
file.close();
}

//getPhoneNumber function, returns phone number for particular person
int phoneBook::getPhoneNumber(string lastN, string firstN)
{
//declaring variables
int i;
int index;
int phoneNum;

//finding matching first name, last name and its index
for(i=0; i<50; i++)
{
    if(lastName[i] == lastN && firstName[i] == firstN)
        index = i;
}

//returning phone number for matching name
phoneNum = phone[index];
return phoneNum;
}

//getDOB function, returns date of birth for a particular person
void phoneBook::getDOB(std::string lastN, std::string firstN, char testDOB[])
{
//declaring variables
int i;
int index;

//finding matching first name, last name and its index
for(i=0; i<50; i++)
{
    if(lastName[i] == lastN && firstName[i] == firstN)
        index = i;
}

//sets the char array which was passed by reference to the date
//of birth of the matched index
for(i=0; i<11; i++)
    testDOB[i] = dateOfBirth[index][i];
 }

//printPhone_DOB function, prints phone number and date of birth for a
//given person
void phoneBook::printPhone_DOB(std::string lastN, std::string firstN)
{
//declaring variables
int i;
int index;

//finding matching first name, last name and its index
for(i=0; i<50; i++)
{
    if(lastName[i] == lastN && firstName[i] == firstN)
        index = i;
}

//printing phone number and date of birth
cout << "Phone number: " << phone[index] << endl;
cout << "Date of birth: ";
for(i=0; i<10; i++)
    cout << dateOfBirth[index][i];
cout << endl;
}

//printNamesForDOB function, print names of people with birthdays on
//given month
void phoneBook::printNamesForDOB(char month[])
{
//declaring variables
int i;

//printing names of people with birthdays in given month
cout << "The folowing people have birthdays in month number " << month << ":" << endl;
for(i=0; i<50; i++)
{
    if(dateOfBirth[i][3] == month[0] && dateOfBirth[i][4] == month[1])
    {
        cout << "Last name: " << lastName[i] << endl;;
        cout << "First Name: " << firstName[i] << endl;
        cout << endl;
    }
}
}

//saveData function, save data back to the local file
void phoneBook::saveData()
{
/*
**Assuming the following data scheme will be put:
**LastName FirstName PhoneNumber DateOfBirth
**(repeating 50 times)
*/

//opening file, deleting its contents
fstream file (filename.c_str(), fstream::out | fstream::trunc); 

//declaring variables
int i, j;

//re-writting new data to file
for(i=0; i<50; i++)
{
    file << lastName[i];
    file << " ";
    file << firstName[i];
    file << " ";
    file << phone[i];
    file << " "; 
    for(j=0; j<10; j++)
        file >> dateOfBirth[i][j];
    file << " ";
    file << endl; //end line
}

//closing file
file.close();
}

File with main function

//Problem 2.cpp
#include "phoneBook.h"
#include <iostream>
using namespace std;

int main()
{
 return 0;
}

Thank you for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:46:48+00:00Added an answer on June 8, 2026 at 10:46 pm

    You have declared a number of static members of your phoneBook class, but you have not provided definitions of those members.

    You will need to provide definitions in your .cpp file like this:

    string phoneBook::lastName[50];
    string phoneBook::lastName[50];
    string phoneBook::firstName[50];
    int phoneBook::phone[50];
    char phoneBook::dateOfBirth[50][10];
    

    I notice also that your constructor declares local variables with the same names as those member variables. This probably isn’t what you want to do, since local variables disappear as soon as the function in which they’re declared exits.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.