Jump to content
  • Advertisement
Sign in to follow this  
garyfletcher

Confusion with boost::shared_ptr - SOLVED

This topic is 4886 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all I have a class
#ifndef GAME_INCLUDE_H
#define GAME_INCLUDE_H

#include "VideoUpdate.h"
#include "GlobalTimer.h"
#include "InputTask.h"
#include "SoundTask.h"
#include <boost/shared_ptr.hpp>

class CApplication : public utility::singleton::Singleton<CApplication>
{
    public:

        boost::shared_ptr<CVideoUpdate> videoTask;
        boost::shared_ptr<CGlobalTimer> globalTimer;
        boost::shared_ptr<CInputTask> inputTask;
        boost::shared_ptr<CSoundTask> soundTask;

        void Run(int argc, char *argv[]);
};

#endif


and am trying allocate to a videoTask pointer with: videoTask(new CVideoUpdate()); But get the following compiler error: no match for call to `(boost::shared_ptr<CVideoUpdate>) (CVideoUpdate*) What am I doing wrong? [Edited by - garyfletcher on July 27, 2005 5:17:54 PM]

Share this post


Link to post
Share on other sites
Advertisement
It is inside the Run() member function:


void CApplication::Run(int argc, char *argv[])
{
/* Stuff */

videoTask(new CVideoUpdate());

/* Stuff */
}


Class CVideoUpdate:

#ifndef INCLUDE_VTASK_H
#define INCLUDE_VTASK_H

#include "InputTask.h"

class CVideoUpdate : public kernel::ITask
{
public:
CVideoUpdate();
virtual ~CVideoUpdate();
unsigned long size(){return sizeof(*this);}

static int scrWidth, scrHeight, scrBPP;
static utility::dator::Dator<int>* screenWidth;
static utility::dator::Dator<int>* screenHeight;
static utility::dator::Dator<int>* screenBPP;

bool Start();
void Update();
void Stop();
};

#endif



ITask:

class ITask
{
public:
ITask(){canKill=false;priority=5000;}
virtual bool Start()=0;
virtual void OnSuspend(){};
virtual void Update()=0;
virtual void OnResume(){};
virtual void Stop()=0;

bool canKill;
long priority;

};



Am stumped???

Share this post


Link to post
Share on other sites
To assign a value to a boost::shared_ptr, you use assignment.

void CApplication::Run(int argc, char *argv[])
{
/* Stuff */

videoTask = boost::shared_ptr<CVideoUpdate>(new CVideoUpdate());

/* Stuff */
}

The code you had treated the videoTask pointer as some sort of function object, which boost::shared_ptr isn't.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!