Skip to content
Snippets Groups Projects
Commit c8b7904f authored by Vojtěch Novotný's avatar Vojtěch Novotný
Browse files

update

parent 789a4537
No related branches found
No related tags found
1 merge request!2DU
...@@ -5,10 +5,12 @@ class TridaA ...@@ -5,10 +5,12 @@ class TridaA
// atributy (data) // atributy (data)
// metody(funkce) // metody(funkce)
public: public:
static int count;
int hodnota; int hodnota;
TridaA(int x) TridaA(int x)
{ {
count++;
hodnota = x; hodnota = x;
std::cout << "Konstruktor TridaA2\n"; std::cout << "Konstruktor TridaA2\n";
} }
...@@ -23,6 +25,7 @@ public: ...@@ -23,6 +25,7 @@ public:
} }
}; };
int TridaA::count = 0;
struct TridaB struct TridaB
{ {
}; };
...@@ -30,9 +33,12 @@ struct TridaB ...@@ -30,9 +33,12 @@ struct TridaB
int main() int main()
{ {
TridaA a, b(5); TridaA a, b(5);
std::cout << "count = " << TridaA::count << std::endl;
TridaA *c = new TridaA(10); TridaA *c = new TridaA(10);
std::cout << "count = " << TridaA::count << std::endl;
std::cout << "a.hodnota = " << a.hodnota << std::endl; std::cout << "a.hodnota = " << a.hodnota << std::endl;
std::cout << "b.hodnota = " << b.hodnota << std::endl; std::cout << "b.hodnota = " << b.hodnota << std::endl;
std::cout << c->hodnota << std::endl; std::cout << c->hodnota << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment