Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <new>
- #include <iomanip>
- template<typename Tip>
- void KreirajMatricu(Tip **&mat, int n)
- {
- try {
- Tip **mat(new Tip*[n]);
- for(int i=0; i<n; i++)
- mat[i]=nullptr;
- try{
- for(int i=0; i<n; i++)
- mat[i]= new Tip[n];
- }
- catch(...) {
- for(int i=0; i<n; i++)
- delete[] mat[i]
- delete[] mat;
- throw;
- }
- }
- catch(...) {
- throw "Alokacija nije uspjela!\n";
- }
- }
- int main()
- {
- double **m(0);
- try {
- KreirajMatricu(m, 10)
- }
- catch(const char poruka[]) {
- std::cout << poruka;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement