Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*20.If a method cannot be inline, if you do not want it to be
- inline or if you want the class definition contain the minimum of
- information, then you must just put the prototype of the method
- inside the class and define the method below the class: */
- #include <iostream>
- using namespace std;
- class vector
- {
- public:
- double x;
- double y;
- double surface(); // The ; and no {} shows it is a prototype
- };
- double vector::surface()
- {
- double s = 0;
- for (double i = 0; i < x; i++)
- {
- s = s + y;
- }
- return s;
- }
- int main ()
- {
- vector k;
- k.x = 4;
- k.y = 5;
- cout << "Surface: " << k.surface() << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment