Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Prog2
/
eloadas_peldak
/
ea_10
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
7931dfa3
authored
May 02, 2019
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kodreszletek
parent
52b0366a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
2 deletions
+52
-2
kodreszletek/kodreszletek.cpp
+52
-2
No files found.
kodreszletek/kodreszletek.cpp
View file @
7931dfa3
...
...
@@ -20,6 +20,9 @@
/// kiíródjanak a képernyőre. Így hatásuk jól megfigyelhető.
#define _(...) std::cout << std::endl << std::setw(50) << std::left << #__VA_ARGS__ << "// "; __VA_ARGS__
/// Sor elejére ír és endl, majd végrehajt
#define __(...) std::cout << std::endl << #__VA_ARGS__ << std::endl; __VA_ARGS__
using
std
::
cout
;
using
std
::
cerr
;
using
std
::
cin
;
...
...
@@ -32,7 +35,7 @@ struct Base {
};
// Der az inicializáló listán hívja Base függvényét,
// amely a Base adattagját adja vissza, de ez még nem inicailizálódott!!!!
// amely a Base adattagját adja vissza, de ez még nem inicailizálódott
!!!!
struct
Der
:
Base
{
int
b
;
Der
()
:
Base
(
b
=
f
())
{
...
...
@@ -40,6 +43,48 @@ struct Der : Base {
}
};
struct
B
{
B
(
int
i
)
{
cout
<<
"B ctor begin"
<<
endl
;
if
(
i
==
0
)
throw
std
::
range_error
(
"B ctor nem futott le!"
);
cout
<<
"B ctor END"
<<
endl
;
}
~
B
()
{
cout
<<
"B dtor"
<<
endl
;}
};
struct
A
{
int
a
;
B
b
;
A
(
int
i
)
try
:
b
(
i
),
a
(
3
)
{
cout
<<
"A ctor begin"
<<
endl
;
if
(
i
==
1
)
throw
std
::
range_error
(
"A ctor nem futott le!"
);
cout
<<
"A ctor END"
<<
endl
;
}
catch
(
std
::
exception
&
e
)
{
// kivételkezelés
cout
<<
e
.
what
()
<<
endl
;
throw
std
::
range_error
(
"A ctor sem futott le!"
);
}
~
A
()
{
if
(
std
::
uncaught_exception
())
cout
<<
"A dtor: rollback folyamatban"
<<
endl
;
else
cout
<<
"A dtor"
<<
endl
;
}
};
void
ctorHiba
(
int
i
)
{
try
{
A
a_obj
(
i
);
cout
<<
"A a_obj leterjott."
<<
endl
;
if
(
i
==
2
)
{
cout
<<
"Most dobunk a fuggvenyben."
<<
endl
;
throw
std
::
range_error
(
"..."
);
}
}
catch
(
std
::
exception
&
e
)
{
cout
<<
e
.
what
()
<<
endl
;
}
}
int
hibas_osztaly
()
{
cout
<<
"Mit ir ki? "
;
cout
<<
"Nem tudjuk!"
<<
endl
;
...
...
@@ -141,6 +186,11 @@ _( return 0;)
int
main
()
{
_
(
hibas_osztaly
();
)
__
(
ctorHiba
(
0
);
)
// B konstruktor dob
__
(
ctorHiba
(
1
);
)
// A konstruktro dob
__
(
ctorHiba
(
2
);
)
// ctorHiba dob
__
(
ctorHiba
(
3
);
)
// nem dob senki
_
(
hibas_osztaly
();
)
tarolok
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment