0% found this document useful (0 votes)
9 views32 pages

Lecture 1 Basic Features of OOP

The document provides an overview of basic features of Object Oriented Programming (OOP), including comparisons between C, C++, and Java in terms of input/output operations, data types, and class structures. It highlights key OOP concepts such as encapsulation, polymorphism, inheritance, and abstraction, along with examples in C++ and Java. Additionally, it discusses the differences between structures and classes, and the significance of constructors and access modifiers.

Uploaded by

malihakhan1030
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views32 pages

Lecture 1 Basic Features of OOP

The document provides an overview of basic features of Object Oriented Programming (OOP), including comparisons between C, C++, and Java in terms of input/output operations, data types, and class structures. It highlights key OOP concepts such as encapsulation, polymorphism, inheritance, and abstraction, along with examples in C++ and Java. Additionally, it discusses the differences between structures and classes, and the significance of constructors and access modifiers.

Uploaded by

malihakhan1030
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Lecture One

Basic Features of
Object Oriented Programming (OOP)

© Dr. Mohammad Mahfuzul Islam, PEng


Professor, Dept. of CSE, BUET
C/C++ Basic I/O

General form of C++ Console I/O


➢ Input Command: cin >> variable;
➢ Output Command: cout << expression;

C Basic I/O C++ Basic I/O


a) Input Statements
scanf(“%s”, strName); cin >> strName;
scanf(“%d”, &iCount); cin >> iCount;
scanf(“%f”, &fValue); cin >> fValue;
scanf(“%d %d %d”, &day, &month, &year); cin >> day >> month >> year;
b) Output Statements
printf(“%s%c%s%c”, “Hello”, ‘ ’, “World”, ‘!’); cout << “Hello” << ‘ ‘ << “World” << ‘!’;
printf(“Value of iCount is: %d”, iCount); cout << “Value of iCount is: ” << iCount;
printf(“Enter day, month, year”); cout << “Enter day, month, year: ”;

2
I/O in C++ Programming
#include <stdio.h> #include <iostream>
int main() { using namespace std;
int a, b, sum; int main() {
char str[16]; int a, b, sum;
char str[16];
printf("Enter number 1: ");
scanf("%d", &a); cout << "Enter number 1: ";

C++ Code
printf("Enter number 2: "); cin >> a;
scanf("%d", &b); cout << "Enter number 2: ";
C Code

printf("Enter a string: "); cin >> b;


scanf("%s", str); cout << "Enter a String: ";
sum = a + b; cin >> str;
printf("The sum is %d : %s", sum, str); sum = a + b;
cout << "The sum is "<< sum << " : " << str;
return 0;
} return 0;
}
Output:
Enter number 1: 12 Output:
Enter number 2: 23 Enter number 1: 14
Enter a string: Love C Programming. Enter number 2: 25
The sum is 35 : Love Enter a String: Love C++ Prog.
Why? How to solve this? The sum is 39 : Love 3
Programming with C++
Two versions of C++:
New version of C++:
Old version of C++:
#include <iostream>
#include <iostream.h>
using namespace std;
int main(){
int main(){
/* program code */
/* program code */
return 0;
return 0;
}
}
➢ Includes filename ➢ Includes stream which is
mapped to file by compiler

Filename used in File stream used in


Bjarne Stroustrup
Old Version New Version (1979)
iostream.h iostream
string.h cstring
math.h cmath
graphics.h cgraphics
4
Comments

➢Multi-line comments
/* one or more lines of comments */

➢Single line comments


// …

5
Some differences between C and C++

SL# Area C C++


1. Empty parameter void is mandatory. void is optional.
list char f1(void); char f1();
2. Function prototype Function prototype is optional but All functions must be prototyped.
recommended.
3. Returning a value ➢A non-void function in not required to ➢If a function is declared as returning a
actually return a value. If it doesn’t, a garbage value, it must return a value.
value is returned. ➢ C++ has dropped the “default-to-int”
➢ “Default-to-int” rule: If a function does not rule.
explicitly specify the return type, an integer
return type is assumed.

4. Local variable Local variables are declared at the start of a Local variables can be declared anywhere.
declaration block, prior to any action statement.
5. bool data type - C++ defines the bool data type and also
keywords true and false.

6
I/O in Java Programming
Notes for Java:
✓ System class of java provides facilities like standard input, standard output and standard
error streams. System class can’t be instantiated. 1. Java does not allow any
✓ Java Scanner is a utility class to read user input or process simple regex-based parsing of variable or function out of a
file or string source. Regex is a short form of regular expression. class.
Scanner Methods:
import java.util.Scanner; • nextBoolean() 2. main() method must be
• nextByte() within a class.
public class Program7 { • nextDouble()
public static void main(String[] args) { • nextFloat() 3. main() method must be
Scanner myObj = new Scanner(System.in); • nextInt()
• nextLine() public and static. Why?
JAVA Code

System.out.print("Enter the first number: "); • nextLong()


• nextShort() 4. A source file may contain
int a = myObj.nextInt();
System.out.print("Enter the second number: "); multiple class or interface; but
int b = myObj.nextInt(); only one of them is public.
Output:
int sum = a + b; Enter the first number: 12 2.The source file name must be
Enter the second number: 34
System.out.println("The sum is "+ sum+ "."); same with public class or
The sum is 46.
} interface name.
}
7
Object-Oriented Programming

Class vs. Object

Student Class Name


Examples
-Name Object
-Student ID Knows Class: Student
-CGPA Object: Lisa, Latif, Mahmud, Habiba
+setName()
+getName() Object
+setStdID() Does
+getStdID() Class: A template or blueprint that defines the properties
+getCGPA() and behaviors of a type of objects.

- means private Object: A specific instance of a class.


+ means public

8
Structure vs. Class
Program8.c

#include <stdio.h>

typedef struct xx{


char name[20];
int rollno;
double cgpa;
} Student;
C Code

int main() { Output:


Student karim; Enter the name: Karim Ahmed
printf("Enter the name: "); Enter Rollno: 12
gets(karim.name); Enter CGPA: 3.85
printf("Enter Rollno: ");
scanf("%d", &karim.rollno); Name: Karim Ahmed
printf("Enter CGPA: "); Rollno: 12
scanf("%lf", &karim.cgpa); CGPA: 3.85
printf(“\nName: %s\n", karim.name);
printf("Rollno: %d\n", karim.rollno);
printf("CGPA: %.2lf\n", karim.cgpa);
}
9
Structure vs. Class
Program8.cpp
int main() {
#include <iostream> Student karim;
#include <string.h> char iname[20];
using namespace std; int irollno;
double icgpa;
typedef struct xx{
private: cout << "Enter the name: ";
char name[20]; // cin >> karim.name; //Error – Why?
int rollno; cin >> iname;

C++ Code
double cgpa; karim.setName(iname);
public: //setter - getter
void setName(char *N){ strcpy(name, N);} cout << "Enter Rollno: ";
char *getName(){return name;} // cin >> karim.rollno; //Error – Why ?
void setRollno(int R){ rollno = R; } cin >> irollno;
int getRollno(){ return rollno;}; karim.setRollno(irollno);
void setCGPA(double CGPA){ cgpa = CGPA;}
double getCGPA(){ return cgpa;} cout << "Enter CGPA: ";
} Student; cin >> icgpa;
karim.setCGPA(icgpa);
Output:
Enter the name: Karim cout << karim.getName() << " ";
Enter Rollno: 12 cout << karim.getRollno();
Enter CGPA: 3.85 cout << " " << karim.getCGPA();
Karim 12 3.85 Does it allow a name as “Karim Ahmed”? Why? }
10
Structure vs. Class

❖ By default, all members of a structure are Public ❖ By default, all members of a class are Private
#include <iostream> #include <iostream>
#include <string.h> #include <string.h>
using namespace std; using namespace std;

typedef struct xx{ class Student{


private: char name[20];
char name[20]; int rollno;

C++ Code
int rollno; double cgpa;
double cgpa; public: //setter - getter
public: //setter - getter void setName(char *N){ strcpy(name, N);}
void setName(char *N){ strcpy(name, N);} char *getName(){return name;}
char *getName(){return name;} void setRollno(int R){ rollno = R; }
void setRollno(int R){ rollno = R; } int getRollno(){ return rollno;};
int getRollno(){ return rollno;}; void setCGPA(double CGPA){ cgpa = CGPA;}
void setCGPA(double CGPA){ cgpa = CGPA;} double getCGPA(){ return cgpa;}
double getCGPA(){ return cgpa;} };
} Student;

11
Use of Class in Java
public class StudentDemo{
❖ Java doesn’t support Structure, Pointer or Union. public static void main(String[] args){
❖ main method – static, public, inside class Student std = new Student();
String iname = new String();
import java.util.Scanner; StudentDemo.java Scanner obj = new Scanner(System.in);
int irollno;
class Student{
double icgpa;
private String name;
private int rollno;
System.out.print("Enter name: ");
private double cgpa;
iname = obj.nextLine();
std.setName(iname);
//setter - getter

Java Code
public void setName(String N){name = N;} System.out.print("Enter Rollno: ");
public String getName(){return name;}
irollno = obj.nextInt();
public void setRollno(int R){ rollno = R; }
std.setRollno(irollno);
public int getRollno(){ return rollno;};
public void setCGPA(double CGPA){ cgpa = CGPA;}
System.out.print("Enter CGPA: ");
public double getCGPA(){ return cgpa;} icgpa = obj.nextDouble();
}
std.setCGPA(icgpa);
Output: System.out.print("Name: " + std.getName()+
Enter name: Abdur Rahim " Rollno: " + std.getRollno() +
Enter Rollno: 12 " CGPA: " + std.getCGPA());
Enter CGPA: 3.85 }
Name: Abdur Rahim Rollno: 12 CGPA: 3.85 }
12
Features of OOP
Three Key Features of OOP
❖ Wrap up data and functions/methods together
Encapsulation ❖ Insulation of data from direct access by the program – data hiding

One Interface, multiple methods


❖ Function overloading:
(1) Use a single name to multiple methods;
Polymorphism
(2) different number and types of arguments.
❖ Operator overloading:
Use of single operator for different types of operands

❖ One class inherits the properties of another class


Inheritance ❖ provide hierarchical classifications
❖ Permits reuse of common code and data

❖ Representing essential features without details


❖ Class defines a list of abstract attributes (data members) and methods to operate on Abstraction
these attributes
13
Encapsulation / Data Hiding
❖ Wrap up data and functions/methods together
class MyClass{
#include <iostream> private int a;
using namespace std; MyClass(){
System.out.println("In Constructor");
class myclass { a = 10;
method int a; }
data public: public int getA(){return a;}
myclass(); // constructor }
method data int geta() { return a;}
Class }; public class Encapsulation{
data
public static void main(String[] args){
method

Java Code
myclass::myclass(){ MyClass ob = new MyClass();
data cout << "In constructor\n"; // System.out.println("a: "+a); Error - Why?
a = 10; System.out.println(ob.getA());
} }
C++ Code

}
int main(){
Interface myclass ob;
(Public method/data)
// cout << a; // wrong -Why?
Output:
cout << ob.geta(); // OK
In Constructor
return 0;
10
}
14
Polymorphism
One Interface, multiple methods
❖ Function overloading: (supported by both C++ & Java)
(1) Use a single name to multiple methods; Function / Constructor Overloading
(2) different number and types of arguments.
❖ Operator overloading: (Java doesn’t support customized operator overloading)
Use of single operator for different types of operands

#include <iostream> date::date(char *str){


#include <cstdio> sscanf(str, "%d%*c%d%*c%d", &day, &month, &year);
using namespace std; }

class date { int main() {

C++ Code
int month, day, year; date sdate("31/12/99");
public: date idate(31, 12, 99);
date(char *str);
date(int d, int m, int y){ sdate.show();
day = d; idate.show();
month = m; return 0;
year = y; }
}
void show(){ Output:
cout << day << '/' << month << '/' ; 31/12/99
cout << year << '\n'; 31/12/99
}
15
};
Polymorphism
import java.time.LocalDate; PolymorphismDemo.java
class MyDate{
public class PolymorphismDemo {
private int day;
private int month; public static void main(String[] args) {
private int year; MyDate sDate = new MyDate("2024-05-12");

JAVA Code
MyDate iDate = new MyDate(23, 7, 2025);
MyDate(String str){
sDate.showMyDate();
LocalDate date = LocalDate.parse(str);
day = date.getDayOfMonth(); iDate.showMyDate();
month = date.getMonthValue(); }
year = date.getYear(); }
}
Output:
MyDate(int newDay, int newMonth, int newYear){ 12/5/2024
day = newDay; 23/7/2025
month = newMonth;
year = newYear;
} Operator overloading: Shall be discussed
a = 4 + 6; in next.
public void showMyDate(){
System.out.println(day+"/"+month+"/"+year); ob1 = ob2 + ob3; Not Supported in Java.
}
}
16
Inheritance
❖ One class inherits the properties of another class
Bird Superclass
❖ provide hierarchical classifications
Attributes
❖ Permits reuse of common code and data Feathers
#include <iostream> Lay eggs Subclass
using namespace std; Nonflying
Flying Bird
Bird
class base { Superclass Attributes Subclass Attributes
int x; … …
public:
void setx(int n) { x = n; } Robin Swallow Penguin Kiwi
void showx() { cout << x << '\n'; }
Attributes Attributes Attributes Attributes
int getx(){ return x; }
… … … …
};
int main(){
class derived: public base { Subclass derived ob;
int y;
public: ob.setx(10); Output:
C++ Code
void sety(int n) { y = n; } ob.sety(20); 10
void showy() { ob.showx(); 20
cout << y << '\n'; ob.showy(); 30
cout << y+getx() <<'\n'; return 0;
} }
};
17
Inheritance
class Base{ public class InheritanceDemo {
private int x; public static void main(String[] args) {
Derived obj = new Derived();
public void setX(int newX){ x = newX;}
public int getX(){ return x;} obj.setX(10);
public void showX(){System.out.println("X = "+x);} obj.setY(20);
} obj.showX();
obj.showY();

Java Code
class Derived extends Base{ }
private int y; }
public void setY(int newY){ y = newY;}
public void showY(){
System.out.println("Y= "+y + " X= "+ getX());
} Output:
} X = 10
Y= 20 X= 10

18
class Rectangle: public Figure{

Abstraction public:
Rectangle(double d1, double d2): Figure(d1, d2){}
double area(){
return dim1 * dim2; Function overriding, but
Abstract Class and Method: } not overloading. Why?
Abstract class is a superclass without a complete implementation };
of every method.
class Triangle: public Figure{
➢ There can be no objects of an abstract class.
public:
➢ Abstract can be used to create object references. Triangle(double d1, double d2): Figure(d1, d2){}
Abstract method refers to subclasser responsibility to override double area(){
it, otherwise, it will report a warning message. return dim1 * dim2 / 2;
➢ Constructor and static method cannot be Abstract. }
};
#include <iostream>
using namespace std; int main(){
Figure *p;

C++ Code
class Figure{ Rectangle r(10, 7);
protected: Triangle t(10, 5);
double dim1, dim2;
p = &r;
public: cout << "Rectangle Area: " << p->area() << endl;
Figure(double d1, double d2){
dim1 = d1; p = &t;
dim2 = d2; cout << "Triangle Area: " << p->area() << endl;
}
virtual double area() = 0; // Pure virtual function return 0;
}; }
19
Abstraction
abstract class Figure { public class Main {
double dim1, dim2; public static void main(String[] args) {
Figure(double a, double b){ dim1 = a; dim2 = b;} Rectangle r = new Rectangle(10,7);
abstract double area(); Triangle t = new Triangle(10, 5);
void show(){System.out.println("Abstract");} Figure figref;

Java Code
}
figref = r;
class Rectangle extends Figure { figref.show();
Rectangle(double a, double b) { super(a, b);}
double area(){ return dim1*dim2;} figref = t;
void show(){ figref.show();
System.out.println("Rectangle Area: "+area()); }
} }
}

class Triangle extends Figure {


Triangle(double a, double b) {super(a, b);} Output:
double area(){ return 0.5*dim1*dim2;} Rectangle Area: 70.0
void show(){ Triangle Area: 25.0
System.out.println("Triangle Area: "+area());
}
} 20
Interface in Java
Abstract class: private /public /protected variable and method declaration / implementation is allowed.
Interface: only static final variable and method declaration is allowed. No method implementation.
Fly.java InterfaceDemo.java
public interface Fly { public class InterfaceDemo {
public String fly(); public static void main(String[] args) {
} Fly doggy = new Dog();
Bird sweety = new Bird();
class Dog implements Fly{ Fly gogon = new Biman();
public String fly(){ return "I cannot fly."; }
public String MakeSound(){ return "I sound berk.";} System.out.println("I am a dog."+ doggy.fly()+ ((Dog) doggy).MakeSound());
} System.out.println("I am a bird."+sweety.fly() + sweety.MakeSound());
System.out.println("I am a Biman." + gogon.fly());
class Bird implements Fly{ }
public String fly() { return "I fly in the sky.";} }
public String MakeSound(){ return "I sound chi-chi.";}
}

class Biman implements Fly{


Output:
public String fly(){ I am a dog.I cannot fly.I sound berk.
return "I fly too high in the sky."; I am a bird.I fly in the sky.I sound chi-chi.
} I am a Biman.I fly too high in the sky.
}
21
Scope Resolution Operator (::) in C++
Scope Resolution Operator is used for two purposes in C++:
To access a hidden global variable To access a hidden member class or member
Program5.cpp variable with a class
Program6.cpp
#include <iostream>
using namespace std; #include <iostream>
using namespace std;
C++ Code

int count = 0;

C++ Code
class X {
int main(void) { public:
int count = 0; static int count;
::count = 1; };
count = 2;
cout << "Global: " << ::count << endl; int X::count = 10;
cout << "Local: " << count;
return 0; int main () {
} cout << "count: " << X::count;
Output: }
Global: 1 Output:
Local: 2 count: 10 22
Namespaces in C++
A namespace is a declarative region that localizes the names of identifiers to avoid name collisions.
Three ways of using namespace.
#include <iostream> #include <iostream>
#include <string> #include <string> #include <iostream>
using std::cin; #include <string>
using namespace std;

C++ Code
int main(){ using std::cout;
std::string str; using std::endl;
using std::string; int main(){
std::cout << "Enter a string: "; string str;
getline(std::cin, str); int main(){
std::cout << str << std::endl; string str; cout << "Enter a string: ";
getline(cin, str);
return 0; cout << "Enter a string: "; cout << str << endl;
} getline(cin, str);
cout << str << endl; return 0;
Output: }
Enter a string: Love C++ return 0;
Love C++
}
Java programming uses separate namespace for each package.
23
Namespaces in C++

➢ C++ library is defined within its own namespace, std. ➢ There are two general form of using statement:

➢The general form of defining namespace is shown as: using namespace name;
namespace name{ using name::member;

} ➢ Declaration of new namespaces are required for


creating library of reusable code or code that requires
Unnamed namespace is declared with the scope of a single file. widest portability.
namespace{
} #include <iostream> int main() {
using namespace std; displayMsg();
int result = add(5, 3);
namespace { cout << "Result: " << result << endl;
void displayMsg() { return 0;
cout << "unnamed namespace." << endl; }
}

int add(int a, int b) { Output:


return a + b; unnamed namespace.
} Result: 8
}
24
Creation of Own Namespaces in C++
#include <iostream> int main() {
using namespace std; firstNS::MyClass ob(10);
namespace firstNS{
class MyClass { ob.setI(99);
cout << "I: " << ob.getI() << endl;
int i;
using firstNS::str;
public:
cout << str << endl;
MyClass(int n) { i = n; }
void setI(int n) { i = n; }
int getI() { return i; } using namespace firstNS;
for( counter = 10; counter; counter--)
};
cout << counter << " ";
cout << endl;
const char* str = "Hello from firstNS!";
int counter = 0;
} secondNS::x = 10;
secondNS::y = 20;

namespace secondNS{
Output:
I: 99 cout << "X: " << secondNS::x << endl;
int x, y; cout << "Y: " << secondNS::y << endl;
Hello from firstNS!
}
10 9 8 7 6 5 4 3 2 1
X: 10 return 0;
Y: 20 }
25
Creation of Own Namespaces in C++

➢There can be more than one namespace declaration of the same name in the same file or
different files.

#include <iostream> int main(){


using namespace std; using namespace Demo;
namespace Demo{
a = b = x = 100;
int a;
cout << "a: " << a << endl;
}
cout << "b: " << b << endl;
cout << "x: " << x << endl;
int x;
return 0;
namespace Demo{
}
int b;
}
Output:
a: 100
b: 100
x: 100
26
Packages in Java
Some more common packages in Java:
public class Main { ➢ import java.lang.*;
import java.time.LocalDate; public static void main(String[] args) { ➢ import java.io.*;
MyDate date = new MyDate("2024-05-12"); ➢ import java.util.*;
class MyDate{ date.showDate();
private int day; } import java.lang.*; is
private int month; } Output: Automatic.
private int year; Date: 12/5/2024
✓ Hierarchical Structure of Packages
MyDate(String str){
LocalDate date = LocalDate.parse(str); ✓ A package contains classes and other
day = date.getDayOfMonth(); subordinate packages
month = date.getMonthValue();
year = date.getYear(); ✓ Leave of a hierarchy is a class name.
} import java.util.*;
class MyDate extends Date{
public void showDate(){ ……………………………………………………
System.out.println("Date: "+ day+"/"+month+"/"+year); }
}
is equivalent to
}
class MyDate extends java.util.Date{
……………………………………………
} 27
Packages in Java
➢ There are no core Java classes in the unnamed default package; all of the standard
classes are stored in some named package.

➢ Java is useless without much of the functionality in java.lang and so, it is implicitly
imported by the compiler for all programs.

➢ If a class with the same name exists in two different imported packages, then
compiler will remain silent and generate a compile-time error if the name is not used
explicitly with the class specifying its package.

➢ when a package is imported, only those items within the package declared as public
will be available to non-subclasses in the importing code.

➢ Packages act as containers for classes and other subordinate packages. Classes act as
containers for data and code.
28
Creation of Own Packages in Java

➢ To create a package, simply include package command as the first statement in


java source file.
package mypack;
➢ If package command is omitted, the class names are put into the default package,
which has no name.
➢ Creating hierarchy of package.
package mypack.prog.myprog;
which is stored as mypack\prog\myprog in windows environment.
➢ A package cannot be renamed without renaming the directory in which classes are
stored.

29
Creation of Own Packages in Java
package mypack;
Command line:
class Balance{
String name; java mypack.AccountBalance
double bal;

Balance(String n, double b){ Incorrect Command:


name = n; java AccountBalance
bal = b;
} AccountBalanace must be qualified with its
void show(){
System.out.println(name + ": $" + bal);
package name.
}
}

class AccountBalance {
public static void main(String[] args) {
Balance[] current = new Balance[3]; Output:
current[0] = new Balance(”Jerry", 123.23); Jerry: $123.23
current[1] = new Balance("Tell", 157.02); Tell: $157.02
current[2] = new Balance("Tom", -12.33); Tom: $-12.33
for(int i=0; i<3; i++) current[i].show();
}
}
30
Good Practices

Setter - Getter Naming Convention


class Student{ 1. Every name should be meaningful.
private String name; Box ix; // Very bad choice
private int stdID;
Box b; // Bad choice
public void setName(String newName){ Box mybox; // Bad choice
name = newName; Box myBox; // Good choice
}

public String getName(){


return name; 2. Class names shall be started with Upper Case; method and
} variable names shall be started with Lower Case.
public void setStdID(int newID){
class myclass; // Bad choice
stdID = newID; class MyClass; // Good choice
} double Val; // Bad choice
int ID; // Bad choice
public int getStdID(){
return stdID; int stdID; // Good choice
} double Count(){…} // Bad choice
} double countName(){…} // Good choice
31
Using Initializer List in C++
#include <iostream>
using namespace std; #include <iostream>
using namespace std; #include <iostream>
class Point{ using namespace std;
int x, y; class Point{
public: int x, y; class Point{
Point(int a = 0, int b = 0){ public: int x, y;
x = a; Point(int a = 0, int b = 0): x(a), y(b) {} public:
y = b; void display(){ Point(int a = 0, int b = 0): x(a), y(b){
}; cout << "x: " << x; cout << "x: " << x;
void display(){ cout << ", y: " << y << endl; cout << ", y: " << y << endl;
cout << "x: " << x; } }
cout << ", y: " << y << endl; }; };
}
}; int main(){ int main(){
Point p1(10, 20); Point p1(10, 20);
int main(){ p1.display(); return 0;
Point p1(10, 20); return 0; }
p1.display(); }
return 0;
}
32

You might also like