//H-File
class My_Class
{
const QStringList const* returnReference();
};
//Cpp-File
const QStringList const* My_Class::returnReference()
{
QDir *dir = new QDir("/");
const QStringList const* strList = new QStringList(dir->entryList(QDir::NoDotAndDotDot));
return strList;
}
So this Code doesn't go.
error: duplicate ‘const’
But a Reference would also not be possible, because then I would return a empty reference. (The QStringList would be deleted afer returning from returnReference())
My Problem is that QDir has no other function. (to gain a Pointer or something on QStringList) So have I overseen something or am I not able to make it const?(const pointer and const state)
'const T *' and 'T const *' mean the same. Perhaps you meant 'const T * const', which is a constant pointer to a constant object. Although I don't see any reason for the pointer itself to be constant.
The QStringList would be deleted afer returning from returnReference()
Ohhh, my mistake. I never used this before. But now it works perfectly. Although the syntax of these two const is a little weird. The first const is before the Type, but the second is after the Type ("Pointer").
The pointer should be const that I can't change it. Const is therefore I think, or not? ;)
Are you sure you want to do this? That is, declare such a pointer as the return type of a public interface of a class? Have you thought about how someone might use such a thing.