A number of them
Last active
November 8, 2019 08:37
-
-
Save barahilia/916161bf6355b6819b7da6b6f44c9a1d to your computer and use it in GitHub Desktop.
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 A { | |
public: | |
int a; | |
A() : a(3) { cout << "A()" << endl; } | |
A(const A& other) : a(other.a) { cout << "A(const A&)" << endl; } | |
A& operator=(const A& other) { a = other.a; cout << "A.operator=(const A&)" << endl; } | |
~A() { cout << "~A()" << endl; } | |
}; | |
int main() { | |
cout << "hi" << endl; | |
A a; | |
A b(a); | |
A c = A(); | |
c = b; | |
return 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> | |
#include <exception> | |
using namespace std; | |
class A { | |
public: | |
int _a; | |
A(int a) throw(exception) | |
: _a(a) | |
{ _a = a; } | |
A(string s) throw(exception); | |
void b() throw(exception) { _a++; } | |
}; | |
A::A(string s) throw(exception) : _a(0) | |
{ _a = 0; } | |
int main() { | |
A aa(5); A bb(""); | |
cout << "Success" << 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> | |
#include <sstream> | |
using namespace std; | |
int main() { | |
cout << "Hi" << endl; | |
stringstream ss; | |
ss << "mama mila ramu"; | |
string s; | |
ss >> s; | |
int i = 42; | |
ss.exceptions ( stringstream::failbit ); | |
try { | |
ss >> i; | |
} catch (exception) { | |
cout << "catched" << endl; | |
} | |
if ( ss.fail() ) cout << "failure 1" << endl; | |
ss.clear(); | |
ss >> s; | |
if ( ss.fail() ) cout << "failure 2" << endl; | |
cout << s << ' ' << i << endl; | |
return 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
template <int N> class D { | |
public: typedef char b[N]; | |
}; | |
int main() { | |
D<0> a; | |
D<-1> b; | |
return 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> | |
class C { }; | |
int main() { | |
std::cout << "C size = " << sizeof(C) << 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
#include <iterator> | |
#include <iostream> | |
#include <fstream> | |
#include <list> | |
using namespace std; | |
int main() { | |
ifstream f("ints.txt"); | |
int test (); | |
list<int> data((istream_iterator<int>(f)), | |
istream_iterator<int>() ); | |
cout << data.size() << endl; | |
copy( data.begin(), | |
--(data.end()), | |
ostream_iterator<int> (cout, " <-> ") ); | |
cout << *data.rbegin() << endl; | |
return 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; | |
typedef void (*foo) (int); | |
void a(int i) { cout << "a(" << i << ')' << endl; } | |
int main() { | |
cout << "Hi" << endl; | |
a(42); | |
foo b( a ); | |
b(7); | |
foo c(); | |
c(); | |
return 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> | |
#include <vector> | |
using namespace std; | |
int main() { | |
vector<double> v; | |
cout << v.max_size() << endl; | |
return 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> | |
#include <boost/smart_ptr.hpp> | |
using namespace std; | |
struct BaseUse { | |
}; | |
struct BaseStream { | |
BaseStream() {cout<<"BaseStream()"<<endl;} | |
template<class T> | |
BaseStream& operator<< (const T& t) { | |
cout << '_' << t; | |
} | |
}; | |
struct Db { | |
template<class T> | |
BaseStream operator<< (const T& t) { | |
BaseStream bs; | |
bs << t; | |
return bs; | |
} | |
}; | |
int main() { | |
cout << "Hi" << endl; | |
Db db; | |
db << "Ura " << 5 << "\n"; | |
return 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; | |
int f(double x) { return int(x*x*x + x*x - x*6); } | |
int main() { | |
cout << "Hi" << endl; | |
for (int y = 10; y>=-10; y--) { | |
for (double x = -3.5; x<=3.5; x+=0.1) { | |
if ( f(x) == y ) { | |
cout << '*'; | |
} else { | |
cout << ' '; | |
} | |
} | |
cout << endl; | |
} | |
return 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
template<typename T> | |
void f1 (T x ) | |
{ | |
g1(x); | |
} | |
void g1(int) | |
{ | |
} | |
int main() | |
{ | |
f1(7); | |
} |
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> | |
template<typename T> | |
T const& max (T const&, T const&); | |
int main() | |
{ | |
std::cout << max(7, 43) << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment