السلام عليكــم ورحمـة الله وبركاتــه ،،
لو سمحتم عندي كود صحيح الحمدلله ماعدا المين فيه مشكله عند هذا السطر
Plants <int>*s=&p ;
الكود هو
#include <iostream>
#include <String>
using namespace std;
template <class T>
class Plants {
private:
string PlantName;
T dataentryID;
public:
//virtual void purefun()=0;
Plants(string type):PlantName(type){};
virtual void setAgefunction();
virtual void printinfo();
virtual void setid();
virtual T getid();
virtual string GetPlantName()const {return PlantName;}
};
template <class T>
class Biennials: public Plants<T>{
private:
int AGE;
T dataentryID;
public:
Biennials():Plants<T>("Biennials"){}
int GetAge()const {return AGE;}
bool setAgefunction(int s)
{
if(s>=2)
{
AGE=s;
cout<<"the age of Perennials" <<AGE;
return true;
}
else
cout<<"Error"<<endl;
}
void printinfo()
{
cout<<"The age of plant is:"<<GetAge()<<endl;
cout<<"Tha id is:"<<getid();
//cout<<"The name is:"<<Plants::GetPlantName();
}
void setid(T r)
{
dataentryID=r;
}
T getid()
{
return dataentryID;
}
};
template <class T>
class Perennials: public Plants<T>{
private:
int AGE;
T dataentryID;
public:
Perennials(): Plants<T>("Perennials"){}
int GetAge() const {return AGE;}
bool setAgefunction(int s)
{
if(s>=2)
{
AGE=s;
cout<<"the age of Perennials" <<AGE;
return true;
}
else
cout<<"Error"<<endl;
}
void printinfo()
{
cout<<"The age of plant is:"<<GetAge()<<endl;
cout<<"Tha id is:"<<getid();
}
void setid(T r)
{
dataentryID=r;
}
T getid()
{
return dataentryID;
}
};
int main()
{
Biennials <int>p();
Plants <int>*s=&p;
s->setAgefunction(2);
s->setid(7);
s->printinfo();
Perennials<int> e;
Plants <int> *p=&e;
p->setAge function(5);
p->setid(3);
p->printinfo();
system("pause");
return 0;
}وشكرا جزيييييييييييييييييييييييييييييييييلا :blush: