root > Coding Blog, Programming, Scala, Software Developer, Finland

linux, ubuntu, software, helsinki


  • Home

  • Categories

  • Archives

  • Tags

  • Search

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 »

aggretion relationship c++

Posted on 2013-12-23

aggretion relationship c++

```c++ //KURTLAR VADİSİ #include using namespace std;

Read more »

virtual destructor

Posted on 2013-12-23

virtual destructor

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

Read more »
1 … 17 18 19 … 21
teaddict

teaddict

203 posts
32 categories
640 tags
RSS
GitHub
© 2019 teaddict