سلام
من این برنامه رو در رابطه با تعداد تکرار یک کاراکتر در رشته رو برای 50 شیء نوشتم ولی نمیدونم اشکال از کجاشه که یک ارور میده .دوستان اگه میشه یه کمکی کنند .
این اروری که میده:
Line 8: error: declaration of 'char* reshte::s' compilation terminated due to -Wfatal-errors.
در خط 8 مگه نباید پوینتر S رو معرفی کرد؟ .یکی بهم گفت باید یا خط 7 رو پاک کنی یا خط 8.
این برنامه :
#include <iostream>
using namespace std;
const int n=50;
class reshte
{
char s[50];
char *s;
char x;
int c;
public:
void input();
void calc();
reshte();
void show();
};
void reshte::input()
{
cin.get(s,50);
cin>>x;
}
reshte::reshte()
{
c=0;
}
void reshte::calc()
{
while (*s)
{
if (*s==x)
{
C++;
s++;
}
}
}
void reshte:: show()
{
cout<<c;
}
int main()
{
int i;
reshte myreshte[n];
for (int i=0;i<50;i++)
myreshte[i].input();
myreshte[i].calc();
myreshte[i].show();
}
ممنون