Skip to content

Commit de85af1

Browse files
committed
add : cpp-programming-questions 08_type_casting 00
1 parent d20bc7b commit de85af1

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

06_operator_overloading_and_friend_function/00_questions.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@
44
🟢 Topic ➡ Operator Overload And Friend Function
55

66

7-
1. Define a class Complex with appropriate instance variables and member functions.
7+
01. Define a class Complex with appropriate instance variables and member functions.
88
Define following operators in the class :-
99
- a. +
1010
- b. -
1111
- c. *
1212
- d. ==
1313

14-
2. Write a C++ program to overload unary operators that is increment and decrement.
14+
02. Write a C++ program to overload unary operators that is increment and decrement.
1515

16-
3. Write a C++ program to add two complex numbers using operator overloaded by a
16+
03. Write a C++ program to add two complex numbers using operator overloaded by a
1717
friend function.
1818

19-
4. Create a class Time which contains hours,minutes and seconds as data members. Write a C++ program using operator overloading for the following :-
19+
04. Create a class Time which contains hours,minutes and seconds as data members. Write a C++ program using operator overloading for the following :-
2020
1. == : To check whether two Times are the same or not.
2121
2. >> : To accept the time.
2222
3. << : To display the time.
2323

24-
5. Consider following :-
24+
05. Consider following :-
2525
class Numbers
2626
{
2727
int x,y,z;
2828

2929
};
3030
Overload the operator unary minus (-) to negate the numbers.
3131

32-
6. Create a class CString to represent a string and define following
32+
06. Create a class CString to represent a string and define following
3333
a. Overload the + operator to concatenate two strings.
3434
b. == to compare 2 strings.
3535

36-
7. Define a class fraction
36+
07. Define a class fraction
3737
class Fraction
3838
{
3939
long numerator;
@@ -46,14 +46,14 @@ Overload the following operators as member or friend:
4646
a. Unary ++ (pre and post both)
4747
b. Overload as friend functions: operators << and >>.
4848

49-
8. Consider a class Matrix
49+
08. Consider a class Matrix
5050
Class Matrix
5151
{
5252
int matrix[3][3], rows = 3, cols = 3;
5353
};
5454
Overload the - (Unary) should negate the numbers stored in the object.
5555

56-
9. Consider the following class mystring
56+
09. Consider the following class mystring
5757
Class mystring
5858
{
5959
char str [100];

06_operator_overloading_and_friend_function/01_overload_arithmetic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
3-
1. Define a class Complex with appropriate instance variables and member functions.
3+
Define a class Complex with appropriate instance variables and member functions.
44
Define following operators in the class :-
55
- a. +
66
- b. -

06_operator_overloading_and_friend_function/03_overload_plus_using_friend_fun.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
/*
2-
3-
1. Define a class Complex with appropriate instance variables and member functions.
4-
Define following operators in the class :-
5-
- a. +
6-
- b. -
7-
- c. *
8-
- d. ==
9-
10-
*/
1+
// // Write a C++ program to add two complex numbers using operator overloaded by a friend function.
112

123
// // Header files
134
#include <iostream>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
3+
0. Write a C++ program to convert Primitive type to Complex type.
4+
Example :-
5+
int main()
6+
{
7+
Complex c1;
8+
Int x=5;
9+
c1=x;
10+
return 0;
11+
}
12+
13+
14+
15+
*/

0 commit comments

Comments
 (0)