-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
c/*.out | ||
c/*.o | ||
cpp/*.out | ||
cpp/ | ||
!cpp/*.cpp | ||
|
||
|
||
java/*.class | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
#include <iostream> | ||
|
||
|
||
class Expression_class { | ||
public: | ||
// Without virtual, the program will gives 0; => Based on declared type | ||
// With virtual => Based on derived classes | ||
virtual bool is_no_expr() {return false;} | ||
}; | ||
|
||
typedef Expression_class* Expression; | ||
|
||
class no_expr_class : public Expression_class { | ||
public: | ||
bool is_no_expr() {return true;} | ||
}; | ||
|
||
int main() { | ||
// Compiler makes decision based on static type information available at compile time | ||
Expression expr = new no_expr_class(); | ||
std::cout << expr->is_no_expr() << std::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
#include <iostream> | ||
#include <string> | ||
using namespace std; | ||
|
||
int main() { | ||
string str; | ||
str = "amazing"; | ||
cout << str << endl; | ||
str = "amaz\"ing"; | ||
cout << str << endl; | ||
str = "amaz\"in\"g"; | ||
cout << str << endl; | ||
str = "amazi""ng"; | ||
cout << str << endl; | ||
str = "amaz'ing"; | ||
cout << str << endl; | ||
str = "ama'z'ing"; | ||
cout << str << endl; | ||
str = "ama\'zing"; | ||
cout << str << endl; | ||
|
||
|
||
|
||
} | ||
|