vendredi 6 octobre 2017

How to use unique_ptr to access class members and class variables in C++

I have a header file where I have defined a class and also used a unique_ptr to access the class members.
But I don't know how to access it from clone.cpp Generally, what we do is create an object of the class For example:

A obj;
bool res = obj.concate("hello");

How can we do it using unique_ptr?

clone.h
--------

std::unique_ptr<class A> obja();

class A
{
public:
  bool concate(string str){
  string a = "hello";
  return a == str;
  }
private:
   string b = "world";
};


clone.cpp
________

int main(){
 auto access = obja();
 return 0;
}

Aucun commentaire:

Enregistrer un commentaire