Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Dependent types

Name: Anonymous 2018-10-12 17:08

So, why are you not using dependent types yet? Do you like your programs randomly crashing?

Name: Anonymous 2018-10-15 4:50

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
template<typename T,size_t size> class contain {private: T arr[size];
public:
T operator [](size_t i) const{
if(!(i<size)){puts("Requested Index out of range. Aborting");exit(2);}
return arr[i];};
T& operator[](size_t i) {
if(!(i<size)){puts("Input Index out of range. Aborting");exit(1);}
return arr[i];};};

int main(){
contain<int,50> A;
int i;
int rts=scanf("%d", &i);
A[i] = 100;
printf("%d", A[i]); return rts;}
Edited on 15/10/2018 04:53.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List