void test2() {
cout << "MAIN CALLED CLASS 1 AND CLASS 1 CALLED CLASS 2 AND THIS MESSAGE WAS DISPLAYED";
}
can someone please explain to me how this works and give me some example code (something like above but works in compiler) of how a simple cout message can be called by the main calling a class and that class calling another class?
thanks.
It doesn't work.
Also, it seems you don't understand what a class is (or at least what "calling" means). A class is just a type. You can't call a class just as much as you can't call an int. You can only call functions.
Now, here's an example that does work:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
class A{
staticvoid f(){
std::cout <<"A::f()"<<std::endl;
}
};
class B{
staticvoid f(){
A::f();
}
};
int main(){
B::f();
return 0;
}
Hello.well,i'm a new forumer.i'm still new to the C++ programming and already got assignments that i could'nt think how to do it.So,i really hope that some of you can help me to do this assignments.Hopefully,i can solve this assignments as soon as possible.Below are the questions:
1.Write a program with function prototype that asks the user to input
-The number of gallons of gas in the tank.
-The fuel efficiency in miles per gallon
-The price of gas per gallon.
Then print the cost per 110 miles and how far the car can go with the gas in the tank.
2.Write a program that can do the following tasks,with no specified input.
a.Read floating number and print the largest value.
b.Read floating number and print the smallest value.
c.Read floating number and print.
d.Read floating number and print the average number.