Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
cv3
#include <iostream> using std::cout; struct TVector { size_t iSize = 0; size_t iCapacity = 0; double *iData = nullptr; }; double Get(TVector &aVec, size_t aIndex) { if(aVec.iSize <= aIndex) throw "Index mimo vektor"; return aVec.iData[aIndex]; } void Set(TVector &aVec, size_t aIndex, double aVal) { if(aVec.iSize <= aIndex) throw "Index mimo vektor"; aVec.iData[aIndex] = aVal; } void AllocVector(TVector &aVec, size_t aSize) // Neni potreba kontrolovat, jestli aVec == nullptr. { // aVec je totiz reference. if(aVec.iData) // aVec je platny https://i.imgflip.com/4hrk9k.jpg it aint much but its honest work throw "Jiz naalokovano"; //while(true) // test bad_alloc // new double[100000000ul]; // aVec.iData = new double[aSize]; aVec.iSize = aSize; aVec.iCapacity = aSize; } void DeallocVector(TVector &aVec) { delete[] aVec.iData; aVec.iSize = aVec.iCapacity = 0; } int main() { TVector v; try { AllocVector(v, 10); Set(v, 9, 5.0); cout << Get(v, 9) << '\n'; } catch(char aStr[]) { cout << "Vyjimka: " << aStr << '\n'; } catch(std::bad_alloc exc) { cout << "Vyjimka bad_alloc: " << exc.what() << '\n'; // exc.what() ... kde vznikla vyjimka } catch(...) { cout << "Obecna vyjimka\n"; } DeallocVector(v); return(0); } //https://rextester.com/live/DFT8522 //Pajoš - musim rici, ze toto byla asi nejlepsi hodina z celych online prednasek a cvik :D //xcharv19 taky souhlas s Pajoš // Petr Safranek - //Anonym - // Samko Janecek - // Tobias - // Marketa- //Jakub Lukaszczyk - Pajoš souhlasím // Stejsky: Potřebuji na záchod. :'( ...už ne. Nemáte niekto hadr ? ano, kam mam donest //nádhera //Timotej Saly - //Microsoft <3 -- miluju tě Pety ????????
run
|
edit
|
history
|
help
0
infix to postfix v 3.0 with improved eval()
Visual Studio 2015 Compiler Bug: 64bit multiplication
Compile time creation of class member stl container (const std::array) filled with elements.
Constant table but dynamic initialization at runtime
calling conventions and using an override class to change another classes values
Override keyword.cpp
additional layer of indirection
delete from list
Affine Key Finder and Decrypter
karma legacy "variant" with attr_cast