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
C++ Inheritance help!?
Started by rossen, Jun 11 2008 04:07 AM
7 replies to this topic
#1
Posted 11 June 2008 - 04:07 AM
|
|
|
#2
Posted 11 June 2008 - 05:19 AM
A very simple example, showing how "Derived" inherits the functionality from "Base".
#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;
}
I don't know what you mean by that formula, could you be more specific?
#3
Posted 11 June 2008 - 05:48 AM
v0id said:
A very simple example, showing how "Derived" inherits the functionality from "Base".
#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;
}
I don't know what you mean by that formula, could you be more specific?I think he meant, a formula, P must be effect and I ampere and T is for time. Thats my guess, which would be likely he wants to enter two numbers and divide them. As I see your small code, its good and will work if he could work on the rest with it :P
#4
Posted 11 June 2008 - 06:00 AM
He can easily implement a member function:
int CalculateP(int I, int T)
{
return I/T;
}
#5
Posted 11 June 2008 - 06:07 AM
v0id said:
He can easily implement a member function:
int CalculateP(int I, int T)
{
return I/T;
}
Wonderful, now he should be able to do the rest I guess xD
#7
Posted 11 June 2008 - 08:58 AM
Wow, I didn't even notice that.
It has been fixed now. Thank you for letting us know.
It has been fixed now. Thank you for letting us know.


Sign In
Create Account

Back to top









