Getter problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef DBMANAGER_H
#define DBMANAGER_H
#include "dbconnection.h"
#include "TSingleton.h"
class DBManager
{
SINGLETON( DBManager )
public:
const AbstractItem**& getItems() const{ return items; }
/* invalid initialization of reference of type 'const AbstractItem**&' from expression of type 'AbstractItem** const' */
private:
AbstractItem** items;
DBManager(){
if(DBConnection::createConnection()){
items= new AbstractItem*[1000];
items= DBConnection::getItemsFromFile("base.txt");
}
}
};
#endif // DBMANAGER_H 


1
2
3
4
5
6
7
//SOME_OTHER_CLASS.cpp
const AbstractItem** items; // declared in .h

SOME_OTHER_CLASS::SOME_OTHER_CLASS(){
dbManager= SINGLETONINSTANCE( DBManager );
items= dbManager.getItems();
}


DBManager contains AbstractItem** (array of pointers to AbstractItem), and I want to make a getter for it. So just basically want to return a const reference, but seems there's an issue with it. Tried without const, const triple pointer and whatnot.

Thanks in advance
Topic archived. No new replies allowed.