Skip to content

Commit e33a39c

Browse files
committed
feat : added preprocessor and namespaces
1 parent f38569e commit e33a39c

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# include<iostream>
2+
using namespace std;
3+
4+
#define max(x,y) (x>y?x:y)
5+
#define msg(x) #x
6+
#define pI 3.1425
7+
#ifndef pI
8+
#define pI 3.1425
9+
#endif
10+
11+
int main()
12+
{
13+
cout<<pI<<endl;
14+
cout<<max(10,12)<<endl;
15+
cout<<msg(hello)<<endl; // converted to string
16+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# include<iostream>
2+
using namespace std;
3+
4+
namespace first
5+
{
6+
void fun()
7+
{
8+
cout<<"first"<<endl;
9+
}
10+
};
11+
12+
namespace second
13+
{
14+
void fun()
15+
{
16+
cout<<"second"<<endl;
17+
}
18+
};
19+
20+
using namespace first;
21+
22+
int main()
23+
{
24+
fun(); // by default first fun is used due to namespace
25+
second::fun();
26+
std::cout<<"Used namespace cout::std"<<endl;
27+
return 0;
28+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy