struct Foo
{
int num;
Foo::Foo() {num = 0;}
void AddToNum() {num+=10;}
};
struct Bar : public Foo
{
int anotherNum;
Bar::Bar() {anotherNum = 0; num = 0;}
}
int main()
{
Bar bar;
Bar.anotherNum = 10;
Bar.AddToNum();
total = Bar.num + Bar.anotherNum;
cout<<total<<endl; //should be equal to 20
return 0;
}
//Bar inherits the num variable and the function to add 10 to it from Foo.
struct A {}; // base class struct B : A {} // derived class (single inheritance).
By learning how to program on C+.
You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.
how to write a program that counts automorphic number from 1 to 999
Divide it by 1000.
No.
Don't write, it is already written, google for 'cpp'.
there is no solution of this problem...........that's it..........
Its limited only by available memory.
Yes.
Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you.
printf ("x")