This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class One_value { | |
public: | |
int a; | |
void set_value (int arg) { | |
a = arg; | |
} | |
// Overload + operator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main () { | |
int a = 5; | |
int b = 10; | |
char c = 'c'; | |
char d = 'd'; | |
bool t = true; | |
bool f = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
template <class T> | |
class Two_values { | |
T a; | |
T b; | |
public: | |
Two_values (T first_arg, T second_arg) { | |
a = first_arg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
template <class T> | |
void custom_add (T a, T b) { | |
cout << "Template result = " << a + b << endl; | |
} | |
int main () { | |
int p = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
template <class T> | |
class Two_values { | |
T a; | |
T b; | |
public: | |
Two_values (T first_arg, T second_arg) { | |
a = first_arg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void custom_add(int a, int b) { | |
cout << "Int result = " << (a + b) << endl; | |
} | |
void custom_add(int a, int b, int c) { | |
cout << "Triple int result = " << (a + b + c) << endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Device { | |
public: | |
virtual void turn_on() = 0; | |
}; | |
class Laptop: public Device { | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Device { | |
public: | |
void turn_on() { | |
cout << "Device is on." << endl; | |
} | |
virtual void say_hello() = 0; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Computer { | |
private: | |
void turn_on() { | |
cout << "Computer is on." << endl; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Device { | |
public: | |
Device() { | |
cout << "Device constructor called" << endl; | |
} | |
}; |
NewerOlder