There are some other methods that are not shown here. But the idea is that I have a method that creates a HTTP Request and returns pointer to classAVariable
Then classAVariable is used by another method to complete the Web Request. I know that some of this is abstract and convoluted. but I inherited these interfaces, not really happy about the set up.
So really the classAVariable is a global variable that I would like to share throughout classA, classB, and classC.
Normally my domain is C#. Can someone please point out the error in my ways!
Couldn't you pass the classAVariable to the method then? It seems strange to me that you would have several classes that interoperate on a global variable to work properly.
classB* classB::classBMethod(classA* classAVariable)
{
// do some work :)
}
I thought about that. I'm pretty sure that would work. Is that the best way to implement this? Just curious, pretty much anyone here has more exp than myself in C++
Without knowing why you need this variable I can't really give you any more details. Like I said before, it seems odd to have a member that all the classes need in order to work. If, from the method's perspective, its just some random data, then there should be no issue in terms of good/bad practice.
// the https response
class HttpsResponse
{
public:
virtual std::string getHeaderValue(std::string key);
virtual std::string getContentAsString();
};
// base class for httpsRequest
class HttpsRequest
{
public:
virtualvoid setHeaderValue(std::string key, std::string value);
virtual HttpsResponse* submit(); //caller takes ownership of result
};
// post request inherits from https request
class HttpsPostRequest : public HttpsRequest
{
public:
virtual Uploader* UploadStream(); //caller takes ownership of result
};
class WebCommunication
{
public:
WebCommunication(HttpsRequest* request, HttpsPostRequest* postRequest);
virtual HttpsPostRequest* makeHttpsPostRequest(std::string uri); //caller takes ownership of result
virtual HttpsRequest* makeHttpsGetRequest(std::string uri); //caller takes ownership of result
private:
AppleHttpsRequest *appleRequest; // not sure I need these
AppleHttpsPostRequest *applePostRequest; // not sure I need these
};