السلام عليكم و رحمة الله وبركاته
عندي سؤال عن الpinters
انا ابغى اخزن عدد n من الذاكرة في ال heap
و ابغى استرجعها
هو السؤال انك تدخل معاملات x و الاس
مثال:
المستخدم يدخل 2x^5+4x^2+1=0
و البرنامج يخرج (2,5),(4,2),(1,0)
باستخدام البوينتر
انا حليتها بس المشكلة يخرج لي اخر شيء ادخل
و هذا هو الكود
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
class poly
{
public:
poly();
void read_c();
void read_p();
void print();
public:
int n;
// poly* next;
poly* term;
int p;
};
poly::poly()
{
n=0;
//next=NULL;
term=NULL;
p=0;
}
void poly::read_c()
{
cout << "Enter the coffection";
cin >> n;
term->n;
}
void poly::read_p()
{
cout <<" Enter its power";
cin >> p;
term->p;
}
void poly::print()
{
cout << n;
cout <<"...."
<<p;
}
int main()
{
poly y;
poly* next=new poly;
next->read_c();
next->read_p();
poly*term;
poly *temp;
for(int i=0;i<4;i++)
{
temp=new poly;
term=temp;
term->read_c();
term->read_p();
//term->temp;
}
for(int j=0;j<5;j++)
{
term->print();
}
return 0;
}الفكرة كيف احجر عدد n من البوينتر و كيف استرجها
و اسف على الإطالة و السلام عليكم و رحمة الله و بركاته
