Issues with qcc

I am not sure if this is the right place to post this. I have a simple
program that compiles on other compilers but not using qcc. If this is not
the correct place, please direct me to where it should go.

In my code I have a polymorphic method in the base class. In the sub class
I would like to overload one of the two methods and still have access to the
other in the base class. The below code is what I was using:

#include <stdio.h>
#include <stdlib.h>


class TestClass
{
public:
virtual void Hello()
{
printf(“Hello\n”);
};
virtual void Hello(int temp)
{
printf(“Hello with int\n”);
};
virtual void Hello1()
{
printf(“Hello1\n”);
};

};

class SubTestClass : public TestClass
{
public:
using TestClass::Hello;
void Hello(int temp)
{
printf(“SubClassHello\n”);
};
};

class SubSubTestClass : public SubTestClass
{
public:
using SubTestClass::Hello;
void Hello(int temp)
{
printf(“SubSubClassHello\n”);
};
};

int main(int argc, char *argv[])
{
TestClass *tc; // base class pointer
SubTestClass *sc = new SubTestClass(); // sub class
SubSubTestClass *ssc = new SubSubTestClass(); // subsub class

printf("\nFirstTest, Set *tc to Subclass and print\n");
tc = sc; // set base class pointer to sub class
tc->Hello();
tc->Hello(1);
sc->TestClass::Hello();
sc->Hello(1);
sc->Hello1();

printf("\nSecondTest, Set tc to ssc and print\n");
tc = ssc; // set base class pointer to subsub class
delete sc;
sc = ssc;
tc->Hello();
tc->Hello(1);
tc->Hello1();
sc->Hello();
sc->Hello(1);
sc->Hello1();
ssc->Hello();
ssc->Hello(1);
ssc->Hello1();
return(0);
}

When I try to compile it I get the following errors:

[temp/inheritancetest] qcc test.cpp -lang-c++ -o test
test.cpp:31: cannot adjust access to void TestClass::Hello(int)' in class
SubTestClass’
test.cpp:28: because of local method void SubTestClass::Hello(int)' with same name test.cpp:41: cannot adjust access to void SubTestClass::Hello(int)’ in
class SubSubTestClass' test.cpp:38: because of local method void SubSubTestClass::Hello(int)’
with same name
test.cpp: In function int main(int, char **)': test.cpp:64: no matching function for call to SubTestClass::Hello ()’
test.cpp:28: candidates are: void SubTestClass::Hello(int)
test.cpp:67: no matching function for call to `SubSubTestClass::Hello ()’
test.cpp:38: candidates are: void SubSubTestClass::Hello(int)
cc: /usr/lib/gcc-lib/ntox86/2.95.2/cc1plus error 33

I believe that the code is correct. I have compiled it with other compilers
and it worked. Is this just not an implemented feature or is is a bug?

Thanks,

Kevin Hykin <kevin.hykin@bepco.com> wrote:

Hello Kevin,

I am not sure if this is the right place to post this. I have a simple
program that compiles on other compilers but not using qcc. If this is not
the correct place, please direct me to where it should go.

In my code I have a polymorphic method in the base class. In the sub class
I would like to overload one of the two methods and still have access to the
other in the base class. The below code is what I was using:

#include <stdio.h
#include <stdlib.h



class TestClass
{
public:
virtual void Hello()
{
printf(“Hello\n”);
};
virtual void Hello(int temp)
{
printf(“Hello with int\n”);
};
virtual void Hello1()
{
printf(“Hello1\n”);
};

};

class SubTestClass : public TestClass
{
public:
using TestClass::Hello;
void Hello(int temp)
{
printf(“SubClassHello\n”);
};
};

class SubSubTestClass : public SubTestClass
{
public:
using SubTestClass::Hello;
void Hello(int temp)
{
printf(“SubSubClassHello\n”);
};
};

int main(int argc, char *argv[])
{
TestClass *tc; // base class pointer
SubTestClass *sc = new SubTestClass(); // sub class
SubSubTestClass *ssc = new SubSubTestClass(); // subsub class

printf("\nFirstTest, Set *tc to Subclass and print\n");
tc = sc; // set base class pointer to sub class
tc->Hello();
tc->Hello(1);
sc->TestClass::Hello();
sc->Hello(1);
sc->Hello1();

printf("\nSecondTest, Set tc to ssc and print\n");
tc = ssc; // set base class pointer to subsub class
delete sc;
sc = ssc;
tc->Hello();
tc->Hello(1);
tc->Hello1();
sc->Hello();
sc->Hello(1);
sc->Hello1();
ssc->Hello();
ssc->Hello(1);
ssc->Hello1();
return(0);
}

When I try to compile it I get the following errors:

[temp/inheritancetest] qcc test.cpp -lang-c++ -o test
test.cpp:31: cannot adjust access to void TestClass::Hello(int)' in class
SubTestClass’
test.cpp:28: because of local method void SubTestClass::Hello(int)' with same name test.cpp:41: cannot adjust access to void SubTestClass::Hello(int)’ in
class SubSubTestClass' test.cpp:38: because of local method void SubSubTestClass::Hello(int)’
with same name
test.cpp: In function int main(int, char **)': test.cpp:64: no matching function for call to SubTestClass::Hello ()’
test.cpp:28: candidates are: void SubTestClass::Hello(int)
test.cpp:67: no matching function for call to `SubSubTestClass::Hello ()’
test.cpp:38: candidates are: void SubSubTestClass::Hello(int)
cc: /usr/lib/gcc-lib/ntox86/2.95.2/cc1plus error 33
I believe that the code is correct. I have compiled it with other compilers
and it worked. Is this just not an implemented feature or is is a bug?

What other compilers have you used?

I see the same problem on Debian (gcc 2.95.4) and FreeBSD (gcc 2.95.3), but
not on my Redhat (gcc 2.96 → beta of 3.0), it looks like the problem is
happening with all gcc’s up to 2.95.x, and work fine with gcc 3.x.

Regards,

Marcin

\

Thanks,

Thanks for the response.

It worked with VC++ Version 6.0. It is interesting that it is working on
gcc 3.x. What would be the implications of using gcc 3.x on RTP? Also, do
you know any other way around having to re-declare all of the polymorphic
methods in a sub class if you just want to override one?

Thanks,





“Tools Mail Account” <tools@qnx.com> wrote in message
news:9ur7ee$sbv$1@nntp.qnx.com

Kevin Hykin <> kevin.hykin@bepco.com> > wrote:

Hello Kevin,

I am not sure if this is the right place to post this. I have a simple
program that compiles on other compilers but not using qcc. If this is
not
the correct place, please direct me to where it should go.

In my code I have a polymorphic method in the base class. In the sub
class
I would like to overload one of the two methods and still have access to
the
other in the base class. The below code is what I was using:

#include <stdio.h
#include <stdlib.h


class TestClass
{
public:
virtual void Hello()
{
printf(“Hello\n”);
};
virtual void Hello(int temp)
{
printf(“Hello with int\n”);
};
virtual void Hello1()
{
printf(“Hello1\n”);
};

};

class SubTestClass : public TestClass
{
public:
using TestClass::Hello;
void Hello(int temp)
{
printf(“SubClassHello\n”);
};
};

class SubSubTestClass : public SubTestClass
{
public:
using SubTestClass::Hello;
void Hello(int temp)
{
printf(“SubSubClassHello\n”);
};
};

int main(int argc, char *argv[])
{
TestClass *tc; // base class pointer
SubTestClass *sc = new SubTestClass(); // sub class
SubSubTestClass *ssc = new SubSubTestClass(); // subsub class

printf("\nFirstTest, Set *tc to Subclass and print\n");
tc = sc; // set base class pointer to sub class
tc->Hello();
tc->Hello(1);
sc->TestClass::Hello();
sc->Hello(1);
sc->Hello1();

printf("\nSecondTest, Set tc to ssc and print\n");
tc = ssc; // set base class pointer to subsub class
delete sc;
sc = ssc;
tc->Hello();
tc->Hello(1);
tc->Hello1();
sc->Hello();
sc->Hello(1);
sc->Hello1();
ssc->Hello();
ssc->Hello(1);
ssc->Hello1();
return(0);
}

When I try to compile it I get the following errors:

[temp/inheritancetest] qcc test.cpp -lang-c++ -o test
test.cpp:31: cannot adjust access to void TestClass::Hello(int)' in class
SubTestClass’
test.cpp:28: because of local method void SubTestClass::Hello(int)' with same name test.cpp:41: cannot adjust access to void SubTestClass::Hello(int)’ in
class SubSubTestClass' test.cpp:38: because of local method void
SubSubTestClass::Hello(int)’
with same name
test.cpp: In function int main(int, char **)': test.cpp:64: no matching function for call to SubTestClass::Hello ()’
test.cpp:28: candidates are: void SubTestClass::Hello(int)
test.cpp:67: no matching function for call to `SubSubTestClass::Hello
()’
test.cpp:38: candidates are: void SubSubTestClass::Hello(int)
cc: /usr/lib/gcc-lib/ntox86/2.95.2/cc1plus error 33
I believe that the code is correct. I have compiled it with other
compilers
and it worked. Is this just not an implemented feature or is is a bug?


What other compilers have you used?

I see the same problem on Debian (gcc 2.95.4) and FreeBSD (gcc 2.95.3),
but
not on my Redhat (gcc 2.96 → beta of 3.0), it looks like the problem is
happening with all gcc’s up to 2.95.x, and work fine with gcc 3.x.

Regards,

Marcin


Thanks,


\