Haval1

Question cpp

Jan 18th, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. // sol-final-ex1.cpp : Defines the entry point for the console application.
  2. /*
  3. suppose you have a class a , where the class contain two var (a and b ) as int
  4. type . construct function to set the var and (out) as output function to print the variable
  5. write a program to do the following
  6.     1. define the class A
  7.     2. Define the object A1 as type of class A
  8.     3. insert values to (a and b)
  9.     4. printting the value of (a and b)
  10. */
  11.  
  12. #include "stdafx.h"
  13. #include "iostream"
  14. using namespace std;
  15. class A {
  16. private:
  17.     int a,b;
  18. public:
  19.     A(int x,int y) {
  20.         a = x;
  21.         b = y;
  22.         cout << "a = " << a << endl;
  23.         cout << "b = " << b << endl;
  24.     }
  25. };
  26. int main()
  27. {
  28.     A A1(4, 5);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment