- Notifications
You must be signed in to change notification settings - Fork360
Inline Using CPP#250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Inline Using CPP#250
Changes fromall commits
Commits
Show all changes
4 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
82 changes: 82 additions & 0 deletionsFriend_function_of_multiple_class1.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| //Friend Function of multiple class | ||
| #include<iostream> | ||
| using namespace std; | ||
| class Second; | ||
| /* | ||
| Prorotype Declaration---->class Second; | ||
| Reason: | ||
| because we are using a friend funtion of multiple class, | ||
| so,when we going to declare compare function as friend of First & | ||
| Second,then at the time of declaration within First class still | ||
| class Second is not defined,So,if we don't write prototype | ||
| declaration the compiler will not identify what is "Second". | ||
| */ | ||
| class First | ||
| { | ||
| private: | ||
| int a; | ||
| public: | ||
| void take_val(); | ||
| void display(); | ||
| friend void compare(First,Second); | ||
| }; | ||
| void First :: take_val() | ||
| { | ||
| cout<<"Enter value for a:\n"; | ||
| cin>>a; | ||
| } | ||
| void First :: display() | ||
| { | ||
| cout<<"a= "<<a<<endl; | ||
| } | ||
| class Second | ||
| { | ||
| private: | ||
| int b; | ||
| public: | ||
| void take_val2(); | ||
| void display2(); | ||
| friend void compare(First,Second); | ||
| }; | ||
| void Second::take_val2() | ||
| { | ||
| cout<<"Enter the value for b:\n"; | ||
| cin>>b; | ||
| } | ||
| void Second :: display2() | ||
| { | ||
| cout<<"b= "<<b<<endl; | ||
| } | ||
| void compare(First F,Second S) | ||
| { | ||
| if(F.a>S.b) | ||
| cout<<"max:"<<F.a; | ||
| else | ||
| cout<<"Max:"<<S.b; | ||
| } | ||
| int main() | ||
| { | ||
| First F1; | ||
| F1.take_val(); | ||
| F1.display(); | ||
| Second S1; | ||
| S1.take_val2(); | ||
| S1.display2(); | ||
| compare(F1,S1); | ||
| return 0; | ||
| } | ||
16 changes: 16 additions & 0 deletionsInline.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| //Inline | ||
| #include<iostream> | ||
| using namespace std; | ||
| inline int Max(int x,int y) //compiler may accept or may not accept | ||
| { | ||
| //it increases the speed of the execution of the code | ||
| //if compiler does not accpet inline request | ||
| return (x>y)?x:y; | ||
| } | ||
| int main() | ||
| { | ||
| cout<<"The result is: "<<Max(20,50)<<endl; | ||
| cout<<"The result is: "<<Max(30,5)<<endl; | ||
| return 0; | ||
| } |
25 changes: 25 additions & 0 deletionsNested_Class.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //One nested class within an outer class | ||
| #include<iostream> | ||
| using namespace std; | ||
| class A | ||
| { | ||
| public: | ||
| class B | ||
| { | ||
| private: | ||
| int n=90; | ||
| public: | ||
| void display() | ||
| { | ||
| cout<<"The result is: "<<n; | ||
| } | ||
| }; | ||
| }; | ||
| int main() | ||
| { | ||
| A::B obj; | ||
| obj.display(); | ||
| return 0; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.