Hi all,
Sorry if this is n00b question.
I'm working on some base classes now, and have a small class
that prints to a QString.
In a higher level class, I want to put that into a QString, but the
compiler complains no matter what I try.
Here's a simplified example
class Dog
{
private:
int age;
public:
Dog(int age);
QString print(); // return dog age in QString
};
class ManyDogs
{
private:
Dog1;
Dog2;
public:
QString printdogs();
}
later:
ManyDogs:rintdogs()
{
QString temp;
temp = Dog1.print();
}
That last line won't compile with an error:
"passing const Dog as 'this' argument of 'QString Dog.print()' discards qualifiers.
And I tried returning "const char *" from print() also, with the same error.
But similar code such as:
printf("Dog age is %s\n". Dog1.print());
works fine. Argh!
Obviously something in the C++ object model I'm not getting.
thanks in advance for any help.
-Don
Bookmarks