Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
My Type - nicro
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//My type nicro #include <iostream> #include <string> using namespace std; template<class T>class nicro{ public: nicro(){} nicro(const nicro& n): val(n.val){} nicro(const T& t) : val(t){} ~nicro(){} nicro& operator =(const nicro& other){ val = other.val; return *this; } int operator <(const nicro& other)const{ return val < other.val; } int operator ==(const nicro& other)const{ return val == other.val; } friend ostream& operator <<(ostream& out, const nicro& n){ out << n.val; return out; } private: T val; }; typedef nicro<double>dNicro; typedef nicro<int>iNicro; void nicro_func(){ dNicro dn1; dNicro dn2(40.25); dNicro dn3(dn2); dNicro dn4(255); dNicro dn5(2*8); iNicro in1(4095); iNicro in2; iNicro in3(in1); iNicro in4(65); dn1 = dn4; cout << "\ndn2 = " << dn2; cout << "\ndn3 = " << dn3; cout << "\ndn1 = " << dn1; cout << "\ndn4 = " << dn4; cout << "\ndn5 = " << dn5; cout << "\n"; cout << "\nin1 = " << in1; cout << "\nin3 = " << in3; in2 = in4; cout << "\nin4 = " << in4; cout << "\nin2 = " << in2; }; int main() { nicro_func(); return 0; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.38 sec, absolute running time: 0.04 sec, cpu time: 0 sec, memory peak: 3 Mb, absolute service time: 0.42 sec
edit mode
|
history
|
discussion
dn2 = 40.25 dn3 = 40.25 dn1 = 255 dn4 = 255 dn5 = 16 in1 = 4095 in3 = 4095 in4 = 65 in2 = 65