c++ - Abstract class and object -


i got first class :

namespace abstract{      class abstractclass{     public:          virtual void setname(const std::string & _name) =0;         virtual void print() =0;         void dynamiccasttest(){};      };  } 

and second :

class concreteclass : public abstract::abstractclass{  std::string type;  public:     concreteclass();     concreteclass(char* a);     ~concreteclass();      static concreteclass* createconcreteclass(char* a);      virtual void setname(const std::string & _name);      virtual void print();   }; 

but when want define function createconcreteclass(char*):

static concreteclass* createconcreteclass(char* a){      concreteclass a;  } 

visual cant create object 'a' because tells me it's abstract object.

why ?

i have tried vc10. gives me error c2082 telling me redefinition of formal parameter (i have german installation error message may different). rename variable:

concreteclass* concreteclass::createconcreteclass(char* a) {     return new concreteclass(a);  } 

edit: added static not returning address of temporary

2nd edit: made createconcreteclass static factory function


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -