Example 1: C++ program to demonstrate the use of class and object
kw.cpp
Output
kodingwindow@kw:~$ g++ kw.cpp
kodingwindow@kw:~$ ./a.out The addition of 10+10=20 kodingwindow@kw:~$
Example 2: C++ program to demonstrate the use of class and object
kw.cpp
Output
kodingwindow@kw:~$ g++ kw.cpp
kodingwindow@kw:~$ ./a.out 20 kodingwindow@kw:~$
Example 3: C++ program to demonstrate the use of class and object
kw.cpp
Output
kodingwindow@kw:~$ g++ kw.cpp
kodingwindow@kw:~$ ./a.out The addition of 10+10=20 kodingwindow@kw:~$
Example 4: C++ program to demonstrate the use of class and object
kw.cpp
Output
kodingwindow@kw:~$ g++ kw.cpp
kodingwindow@kw:~$ ./a.out Enter the 1st number 10 Enter the 2nd number -50 The addition of 10-50 = -40 kodingwindow@kw:~$
What Next?
C++ program to demonstrate the use of constructors and destructors
C++ program to print the addition of numbers using constructor
C++ Functions
Advertisement