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 8895493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:47:43+00:00 2026-06-14T23:47:43+00:00

Basicaly this is my assignment project for C++ and i’m pretty new to C++

  • 0

Basicaly this is my assignment project for C++ and i’m pretty new to C++ and i’m getting this error up. Also having an error for the commented code in main == is not a matched operand

1>Main2.obj : error LNK2019: unresolved external symbol “class std::basic_ostream > & __cdecl operator<<(class std::basic_ostream > &,class Customer &)” (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@AAVCustomer@@@Z) referenced in function “void __cdecl display(struct Node *)” (?display@@YAXPAUNode@@@Z)

Here is the code Main.cpp

    #include <iostream>
    #include "account.h"
    #include "cheque.h"
    #include "customer.h"


    using namespace std;

    struct Node {
    Node* m_next;
    Customer& m_customer;
    Node(Customer& customer) : m_next(0), m_customer(customer) {}   
    };

   // only for the 1st Node
    void initNode(struct Node *head,Customer n){
head->m_customer = n;
head->m_next =NULL;
    }

     // apending
    void addNode(struct Node *head, Customer n) {
Node *newNode = new Node(n);
newNode->m_customer = n;
newNode->m_next = NULL;

Node *cur = head;
while(cur) {
    if(cur->m_next == NULL) {
        cur->m_next = newNode;
        return;
    }
    cur = cur->m_next;
}
    }


    void insertFront(struct Node **head, Customer n) {
Node *newNode = new Node(n);
newNode->m_customer = n;
newNode->m_next = *head;
*head = newNode;
    }

    //struct Node *searchNode(struct Node *head, Customer n) {
//Node *cur = head;
//while(cur) {
    //if(cur->m_customer == n) return cur;
    //cur = cur->m_next;
//}
//cout << "No Node " << n << " in list.\n";
    //}

    bool deleteNode(struct Node **head, Node *ptrDel) {
Node *cur = *head;
if(ptrDel == *head) {
    *head = cur->m_next;
    delete ptrDel;
    return true;
}

while(cur) {
    if(cur->m_next == ptrDel) {
        cur->m_next = ptrDel->m_next;
        delete ptrDel;
        return true;
    }
    cur = cur->m_next;
}
return false;
     }

     void deleteLinkedList(struct Node **node)
    {
struct Node *tmpNode;
while(*node) {
    tmpNode = *node;
    *node = tmpNode->m_next;
    delete tmpNode;
}
    }

    void display(struct Node *head) {
Node *list = head;
while(list) {
    cout << list->m_customer << " ";
    list = list->m_next;
}
cout << endl;
cout << endl;
     }

    int main() 
     {
     Customer test1("sdfs","sdf2","dsfpppsf","fdgdfg","fdgdsffg");

struct Node *newHead;
struct Node *head = new Node(test1);


Customer test2("sdsffs","sdfhhmj2","dsfhfsf","fdgdfgs","fdsggdfg");
Customer test3("sdsdfs","sdllllf2","dsfldfgsf","fdgaghdfg","fdgbvcbdfg");
Customer test4("sdgnfgfs","ssdfsdf2","dsfhjhdsf","fdbvcgdfg","fdgsfddfg");

addNode(head,test2);
display(head);

addNode(head,test3);
display(head);

insertFront(&head,test4);
display(head);

cout << "Deleting the copied list\n";
deleteLinkedList(&newHead);
display(newHead);
return 0;
     }

Customer.cpp

    #include "customer.h"

    using namespace std;


     Customer::Customer(string init_name, string init_address, string init_telephone, string init_sex, string init_dob)
        {
      name = init_name;
address = init_address;
telephone = init_telephone;
sex = init_sex;
dob = init_dob;
     }


           void Customer::showPersonDetails(void)
           {
        cout << "Name : " 
        << name << endl;
        cout << "Address : " 
        << address << endl ;
        cout << "Telephone : " 
        << telephone << endl;
        cout << "Sex : " 
        << sex << endl ;
        cout << "Date of Birth : " 
        << dob << endl;
           }

and finally customer.h

  #ifndef CUSTOMER_H
      #define CUSTOMER_H

  #include <iostream>
  #include<string>

 using namespace std;

  class Customer
   {
   private:
     //
     // class members
     //
     string name; 
     string address;
     string telephone;   
     string sex;
     string dob;

   public:

     // Constructor
     Customer(string init_name, string init_address, string init_telephone, string init_sex, string init_dob);   

     // a print method
     void showPersonDetails(void);
     void changeDetails(void);

     // This operator is a friend of the class, but is NOT a member of the // class:
     friend ostream& operator <<(ostream& s, Customer& a);

        };  

        // This is the prototype for the overload
       ostream& operator <<(ostream& s, Customer& a);

           #endif
  • 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-14T23:47:44+00:00Added an answer on June 14, 2026 at 11:47 pm

    In your header you have the following declaration:

    // This operator is a friend of the class, but is NOT a member of the class:
    friend ostream& operator <<(ostream& s, Customer& a);
    

    You don’t have a definition in your cpp file – you need to provide a definition.

    ostream& operator <<(ostream& s, Customer& a)
    {
        s << a.name << ... etc...
        return s;
    }
    

    The reason you’re having a linker error is because the declaration exists, but not the definition.

    In Main.cpp you have the display function which uses operator<< for Customer:

    void display(struct Node *head) {
    Node *list = head;
    while(list) {
        cout << list->m_customer << " "; // this line here uses operator<< for Customer
        list = list->m_next;
    }
    

    It compiles because operator<< exists in the header, so the symbol can be found… but in the linking stage the object definition (the body of operator<<) cannot be found – so you get an unresolved external linker error.

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

Sidebar

Related Questions

First off this is for homework or... project. I'm having trouble understanding the idea
UPDATED: SEE BELOW I've been porting the code for this assignment: http://www.stanford.edu/class/cs221/progAssignments/PA1/search.html (the entire
First of all this is a homework assignment so I'm looking for assistance, not
So basically this code: class A { }; class B { B (const B&
So basically this code was working fine before. I had some computer issues and
I have (basically) this code - <script type=text/javascript language=javascript> $(document).ready(function() { $(#loadDiv).load(mypage.html, function(){ alert($(#someText).text())
I'm working on a new CMS to use on repeative projects. Basically this chunk
I'm working on this assignment: http://www.cs.colostate.edu/~anderson/ct310/index.html/doku.php?id=assignments:assignment_2 I'm building a binary tree in Javascript. Basically
So I'm having issues overloading the assignment operator when working with templates. Basically, I'm
This maybe a related question: Java assignment issues - Is this atomic? I have

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.