'Compiler error - is private within this context - Line 31

#include<iostream>
#include<string>
using namespace std;

class Item{
    private:
        string type;
        string abbrv;
        string uID;
        int aircraft;
        double weight;
        string destination;
    public:
        void print(){
        cout << "ULD: " << type << endl;
        cout << "Abbreviation: " << abbrv << endl;
        cout << "ULD-ID: " << uID << endl;
        cout << "Aircraft: " << aircraft << endl;
        cout << "Weight: " << weight << " Kilograms" << endl;
        cout << "Destination: " << destination << endl;
   }

    friend void kilotopound(Item);
};
void kilotopound(Item I){
    cout << "Weight in Pounds: " << I.weight * 2.2 << " LBS " << endl;
}

int main(){
   Item I;
   I.type = "Container";
   I.uID = "AYK68943IB";
   I.abbrv = "AYK";
   I.aircraft = 737;
   I.weight = 1654;
   I.destination = "PDX";
   I.print();
   kilotopound(I);

   return 0;
}

Starting on line 31 I'm getting the error 'std::__cxxll::string Item::type' is private within this context

I'm basically trying to make the data private from this code

class Item{
    public:
        string type;
        string abbrv;
        string uID;
        int aircraft;
        double weight;
        string destination;
    void print(){
        cout << "ULD: " << type << endl;
        cout << "Abbreviation: " << abbrv << endl;
        cout << "ULD-ID: " << uID << endl;
        cout << "Aircraft: " << aircraft << endl;
        cout << "Weight: " << weight << " Kilograms" << endl;
        cout << "Destination: " << destination << endl;
   }

    friend void kilotopound(Item);
};
void kilotopound(Item I){
    cout << "Weight in Pounds: " << I.weight * 2.2 << " LBS " << endl;
}

int main(){
   Item I;
   I.type = "Container";
   I.uID = "AYK68943IB";
   I.abbrv = "AYK";
   I.aircraft = 737;
   I.weight = 1654;
   I.destination = "PDX";
   I.print();
   kilotopound(I);

   return 0;
}

Any help would be greatly appreciated, I'm just sort of lost on how I can resolve the error. Thanks!

Also I need to be able to copy and output the copied data once again if anyone can help with that as well, with private data too. Thanks again!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source