Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
Sirajmolla merged 4 commits intocoder2hacker:mainfromPiyali31:main
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletionsFriend_function_of_multiple_class1.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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;
}

[8]ページ先頭

©2009-2025 Movatter.jp