root > Senior Software Engineer | Scala, AWS, Kubernetes, Microservices, Python, Go, PostgreSQL

Technical Blog: Functional Programming, Cloud Architecture & DevOps


  • Home

  • Categories

  • Archives

  • Tags

  • Search

how to use lists with abstract class

Posted on 2014-01-02

how to use lists with abstract class

```c++ #include #include using namespace std;

Read more »

output 3 virtuality

Posted on 2014-01-01

output 3 virtuality

#include<iostream>
using namespace std;
class BC{
public:
void show_class(){
show1();
show2();
}
private:
void show1(){
cout << "#1 BC\n";
}
virtual void show2(){
cout << "#2 BC\n";
}
};
class DC : public BC{
private:
void show1(){
cout << "#1 DC\n";
}
virtual void show2(){
cout << "#2 DC\n";
}
};
class DDC : public DC{
private:
void show1(){
cout << "#1 DDC\n";
}
virtual void show2(){
cout << "#2 DDC\n";
}
};
int main()
{
BC b;
b.show_class(); // #1 BC, #2 BC 
cout << endl;
DC d;
d.show_class(); // #1 BC , #2 DC
cout << endl;
DDC dd;
dd.show_class(); // #1 BC , #2 DDC 
cout << endl;   // show_class is in BC class, so it shows its show1() function because of no virtuality
return 0;
}
Read more »

output 2 inheritance

Posted on 2014-01-01

output 2 inheritance

#include <iostream>
using namespace std;
class One{
public:
int F(){return 2;}
virtual int G(){return 3;}
};
class Two: public One{
public:
int F(){return 4;}
int G(){return 5;}
};
class Three: public Two{
public:
int G(){return 7;}
};
int main()
{
One * p1;
One ob1;
Two ob2;
Three ob3;
p1 = &ob1; //  base 
cout << p1->F() * p1->G(); // = 6
cout << endl;
p1 = &ob2;
cout << p1->F() * p1->G(); // int F() is not virtual therefore 
cout << endl;              // it take the base function =2*5 =10
p1 = &ob3;
cout << p1->F() * p1->G(); // 2*7 = 14
cout << endl;
Two * p2;                  
p2 = &ob3;
cout << p2->F() * p2->G(); // 4 * 7 = 28 the f() function from Two
cout << endl;              // there is virtual G function...
return 0;
}
Read more »

output inheritance

Posted on 2014-01-01

output inheritance

```c++ #include using namespace std; class Base{ private: int i; protected: int j; int get_i() { return i;} public: int k; Base() {i=2; j=4; k=6;} }; class Der1: public Base{ public: Der1(){k = 17;} int getI() {return get_i();} }; class Der2: public Der1{ public: Der2(){k = 15;} };

Read more »

finals part one

Posted on 2014-01-01

finals part one

```c++ #include

Read more »

pessoa pessoa pessoa ^^

Posted on 2013-12-29

pessoa pessoa pessoa ^^

Read more »

list c++ class

Posted on 2013-12-28

list c++ class

Read more »

vector class c++

Posted on 2013-12-28

vector class c++

Read more »

vector c++

Posted on 2013-12-28

vector c++

```c++ #include #include using namespace std;

Read more »

exception handling

Posted on 2013-12-28

exception handling

```c++ #include #include using namespace std;

Read more »
1 … 17 18 19 … 21
teaddict

teaddict

205 posts
37 categories
645 tags
RSS
GitHub
© 2025 teaddict