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

  • Home
  • SEARCH
  • 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 6538873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:47:18+00:00 2026-05-25T10:47:18+00:00

I’ve been instructed to create two Classes: Customer and Barber, Barber should have a

  • 0

I’ve been instructed to create two Classes: Customer and Barber,
Barber should have a function : cutHair() that can change the value of private member hairLength in Customer.

Customer.h

#ifndef CUSTOMER_H
#define CUSTOMER_H
#include "barber.h"
#include <iostream>
#include <string>
using namespace std;  

class Customer{
    public:
        friend void Barber::cutHair(Customer &someGuy);
        Customer(string name, double hairLength);
        string getName();
        double getHair();
        void setHair(double newHair);
    private:
        string name;
        double hairLength;
};
#endif

Barber.h

#ifndef BARBER_H
#define BARBER_H
#include <iostream>
#include <string>
#include "customer.h"
using namespace std;
class Customer;
class Barber{
    public:
        Barber(string barberName);
        void cutHair(Customer &someGuy);
    private:
        string name;
        double takings;
};
#endif

barber.cpp EDIT: I changed the implementation of cutHair() to take advantage of the friend declaration instead of accessing the private members of class Customer through it’s public accessor methods

#include "barber.h"
#include <string>

Barber::Barber(string barberName){
        name = barberName;
        takings = 0;
}
void Barber::cutHair(Customer &someGuy){
        takings += 18;
        someGuy.hairLength = someGuy.hairLength * 80 / 100; 
}

customer.cpp

#include "customer.h"
#include <string>

Customer::Customer(string customerName, double custHairLength){
        name = customerName;
        hairLength = custHairLength;
}
double Customer::getHair(){
        return hairLength;
}
void Customer::setHair(double newLength){
        hairLength = newLength;
}

when attemping to build i get the error message

customer.h(10): error C2653: 'Barber' : is not a class or namespace name

been doing research and canceling out issues one after another for a few days now.
hope someone can come to my rescue 🙂

  • 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-05-25T10:47:19+00:00Added an answer on May 25, 2026 at 10:47 am

    In Barber.h you are forward declaring Customer (class Customer;) AND including #include Customer.h". Try removing the include. Of course you will have to add the include in your Barber.cpp

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has

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.