Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Teatime Snack
//g++ 7.4.0 #include <iostream> #include <string> using namespace std; class Snack;//Snack will declare a friend class so this solitary line is needed. class Teatime{ int price, plate; public: int cost() { return (price *plate); } void get(Snack a); }; class Snack{ friend class Teatime;//class Teatime is declared a friend to class Snack; so Teatime members have access to Snack class members; not the other way as Teatime did not treat class Snack as friend. private: int price, qty; public: Snack (int p, int q) : price (p), qty(q) {} }; void Teatime::get(Snack a) { price = a.price; plate= a.qty; } int main() { Teatime tt; Snack s(5,4); tt.get(s); cout <<"Tea time snack costs Tk "<<tt.cost()<<endl; return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Stats - Central Limit Theorem - Normal Distribution with multiple items
1234
NWD
Continuous Sub Set with given sum
11340 v3.0
array, loop, function examples
Couting number of substring occurances in C++
Find the Duplicate Number in array of n+1 integers having elements from 1 to n
Sort row sorted matrix
without HLD range Quey can be handled by just using segment tree on the FLATTENED TREE (euler tour)
Please log in to post a comment.