الثلاثاء، 24 ديسمبر 2013
2:22 ص

class with pointer instead of object

// ConsoleApplication31.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<conio.h>
using namespace std;
class complex
{
private:
float real;
float imag;
public:

void getdata(float a, float b)
{
real = a;
imag = b;
}
void display()
{
cout << real << " +j" << imag << "\n";
}
};
void main()
{
complex *p;
p = new complex;
int x, y;
cout << "enter two number: ";
cin >> x >> y;
p->getdata(x,y);
cout << "\n the complex number is : ";
p->display();
_getch();
}

0 التعليقات:

إرسال تعليق

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
اضغط على الابتسامة لظهور الكود الخاص بها
لإدراج تعبيرات الوجه يجب إضافة ما لا يقل عن مسافة واحدة قبل رمز.