C++ program to define the member function inside and outside the class and illustrate the use of scope resolution operator
Code:
#include<iostream>
using namespace std;
class book
{
string title;
int price;
public:
book()
{
title = "oop";
price = 500;
}
void display();
};
void book :: display()
{
cout << " Code by Code Champ "<< endl;
cout << " Title of book "<< title<<endl;
cout << " Price of book "<< price<<endl;
}
int main()
{
book b1;
b1.display();
return 0;
}
Result/Output:
For more follow on Instagram: Code Champ
Draw Shin Chan using Python Turtle: https://youtu.be/JqS5NJV2chk
Draw Doremon using Turtle in python : https://youtu.be/mfPfSERU2K0
Print name using Python Turtle: https://youtu.be/5XcSBJqQMIc
Indian Flag using Python Turtle: https://youtu.be/XSulTcyWAoE
Amazing Design/ pattern using Python Turtle: https://youtu.be/fIYzTIjJdT4
Amazing 2Design/ pattern using Python Turtle: https://youtu.be/5gX09uVdjlo
Difference between C++ and Java: https://youtu.be/oSLL27bIXKQ
OOPS concept in Java : https://www.instagram.com/p/CUefM7nvMLH/
Java Features : https://www.instagram.com/p/CT71x2_h7SW/
Types of application in java: https://www.instagram.com/p/CUIBrSmv6LM/
Best Java ides 2021: https://www.instagram.com/p/CUbrDCevaVE/
No comments: