Как вы обрабатываете ошибку «невозможно создать экземпляр абстрактного класса» в C++?

Как вы обрабатываете ошибку «невозможно создать экземпляр абстрактного класса» в C++? Я просмотрел некоторые из похожих ошибок здесь, и ни одна из них не кажется точно такой же или проблемой, с которой я сталкиваюсь. Но, опять же, я признаю, что есть несколько, чтобы пройтись. Вот ошибка компиляции:

[IMG]http://i67.photobucket.com/albums/h292/Athono/cannotinstantiateabstractclass.png[/IMG]

Это приводит меня на эту страницу: http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(C2259 );k (VS.ERRORLIST )&rd=true Ошибка компиляции C2259 связана с программой C++, но страница называет абстрактный класс «интерфейсом» :

Whenever you derive from an interface and implement the interface methods in the derived class with access permissions other than public, you may receive C2259. This occurs because the compiler expects the interface methods implemented in the derived class to have public access. When you implement the member functions for an interface with more restrictive access permissions, the compiler does not consider them to be implementations for the interface methods defined in the interface, which in turn makes the derived class an abstract class.

There are two possible workarounds for the problem:

Make the access permissions public for the implemented methods.

Use the scope resolution operator for the interface methods implemented in the derived class to qualify the implemented method name with the name of the interface.

. Плохая новость заключается в том, что я уже сделал все методы общедоступными в классе :

class AmbientOccluder: public Light {
    public:

        AmbientOccluder(void); 

-. 121 ---912851-

Асинтаск :передает два или более значения из doInBackground в onPostExecuteУ меня есть Asynctask, который извлекает два значения int, и я хочу передать их onPostExecute, чтобы показать их в представлении. Вот мой код :открытый класс QueryServer расширяет AsyncTask

У меня есть Asynctask, который извлекает два значения int, и я хочу передать их onPostExecute, чтобы показать их в представлении.
Вот мой код:

    public class QueryServer extends AsyncTask  { 

    protected Integer doInBackground(String... serverAddress) {
        Log.d("QueryServer", ""+serverAddress[0]);
        MCQuery mcQuery = new MCQuery("" + serverAddress[0],25565);
        QueryResponse response = mcQuery.basicStat();

        int Onlineplayers = response.getOnlinePlayers(); //first vaule
        int Maxplayers = response.getMaxPlayers();  //second vaule

        Log.d("MCQuery", "" + Onlineplayers + " OnlinePlayers");
        return Onlineplayers;

    }

    protected void onPostExecute(Integer Onlineplayers){

        TextView onlinePlayersView = (TextView) findViewById(R.id.online_players);

        onlinePlayersView.setText(""+Onlineplayers+"/"+ Maxplayers); //i need to pass Maxplayers to use it here


    }

Заранее спасибо.

23
задан Boris 6 August 2012 в 18:41
поделиться