|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
can anyone make a C++ program with the use of inheritance?
and with the use of this formula: P=I/T thanks, ----------------------------------------- Girly Myspace Layouts become a vegetarian |
| Sponsored Links |
|
|
|
|||||
|
A very simple example, showing how "Derived" inherits the functionality from "Base".
Code:
#include <iostream>
class Base
{
public:
void basefunction() { std::cout << "In Base" << std::endl; }
};
class Derived : public Base
{
public:
void derivedfunction() { std::cout << "In Derived" << std::endl; }
};
int main()
{
Base b;
Derived d;
b.basefunction();
d.basefunction();
d.derivedfunction();
return 0;
}
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
|
|||||
|
He can easily implement a member function:
Code:
int CalculateP(int I, int T)
{
return I/T;
}
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
|
|||||
|
What's this doing in the C# forum?
|
|
|||||
|
Wow, I didn't even notice that.
It has been fixed now. Thank you for letting us know.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
|
|||||
|
Welcome.
![]() |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Questions about Class inheritance | njr1489 | C# Programming | 1 | 03-31-2008 11:47 AM |
| Xav | ........ | 1455.48 |
| MeTh0Dz|Reb0rn | ........ | 1089.45 |
| WingedPanther | ........ | 977.76 |
| marwex89 | ........ | 962.9 |
| John | ........ | 914.37 |
| morefood2001 | ........ | 911.18 |
| Brandon W | ........ | 823.79 |
| chili5 | ........ | 312.39 |
| Steve.L | ........ | 276.28 |
| dcs | ........ | 253.49 |
Goal: 100,000 Posts
Complete: 84%