F
foodic
Hi all,
I am new to c++ I have a problem compiling this program,
#include <iostream.h>
class iq
{
protected :
int k;
public :
iq(int k){
this->k=k;
}
virtual void printiq(){}
};
class im : public iq
{
int l;
public :
im(int k):iq(k) {
this->l=k;
}
void printiq(){
cout <<l;
}
};
int main(){
im l(10);
iq *l;
((l)iq*)->printiq();
}
Basically I want to acess the derived class member function
through pointer to the Base class. When i compile this program
it gives error like,
inherit.c: In function `int main ()':
inherit.c:26: conflicting types for `iq *l'
inherit.c:25: previous declaration as `im l'
inherit.c:27: parse error before `*'
How to solve this problem,
divya
I am new to c++ I have a problem compiling this program,
#include <iostream.h>
class iq
{
protected :
int k;
public :
iq(int k){
this->k=k;
}
virtual void printiq(){}
};
class im : public iq
{
int l;
public :
im(int k):iq(k) {
this->l=k;
}
void printiq(){
cout <<l;
}
};
int main(){
im l(10);
iq *l;
((l)iq*)->printiq();
}
Basically I want to acess the derived class member function
through pointer to the Base class. When i compile this program
it gives error like,
inherit.c: In function `int main ()':
inherit.c:26: conflicting types for `iq *l'
inherit.c:25: previous declaration as `im l'
inherit.c:27: parse error before `*'
How to solve this problem,
divya