c++ - Accessing private variable from a friend class - I believe my syntax is wrong -
okay, parking ticket application... i'm sure you've seen/done them before. 1 c++ , i'm having trouble getting class-contained methods access private members of friend class. know syntax error, can't seem find example makes sense me on syntax is.
this (one of) lines errors on. they're same error,
cout<<"please visit local police department issued "<<policeofficer.name<<" badge number "<<policeofficer.badgenumber <<" pay $"<<fine<<" fine.";
and here beginning of policeofficer class, in case haven't appropriately declared friend status between classes.
class policeofficer { private: string name, badgenumber; public: friend class parkedcar; friend class parkingmeter; friend class parkingticket;
there's couple of errors. "error c2027: use of undefined type" "left of '.badgenumber' must have class/struct/union" "type name not allowed" "identifier createticket undefined"
but center around single line of code, plus few others have written same exact way.
sorry if i've missed necessary, i'd more happy provide more information if did.
policeofficer name of class , trying access private member variable using class name giving error. create object of policeofficer obj , access variable obj.badgenumber.
Comments
Post a Comment