I am trying a New project on Serial Devices and came across this Syntax which i couldn,t Understand how are u declaring a Serial Device using its address in the structure.
by the way, as you instantiated something with new, this class needs a destructor where you call delete (and copy constructor and copy assignment operator likely)
if you declare the object as a Stream (if that was your hint), then you can't use listen() which will be needed to handle multiple SoftwareSerial lines in parallel.
I am able to listen to the ports but i need to do it one after another which i have no problem in.
And yes i found the post Serial port as a variabe helpful cause i can access more no of ports on MEGA and store the data corresponding to it in the structure or class as well as booleans and other variables also.
Thank u everyone i guess this post would be open in case of another doubt or error
unless you have a very specific project where you control when the modules attached to the serial ports "speak" to you (ie you ping them, they answer otherwise they are quiet), and that the flow is reasonable and you don't need to go faster than 9600 bauds then using multiple SoftwareSerial is just calling for trouble..
get a proper hardware with multiple hardware ports...
To introduce the rule as training practice since OP wanted to do a class. (I was looking for an answer with more code but no destructor, so. a learning opportunity but did not happen)
The concern of resource management should be cleanly separated from the application logic that actually uses the SoftwareSerial instance. Such a resource management class should then follow the rule of three/five, and the class that uses it should follow the rule of zero.
If you have access to the standard library, you can use std::unique_ptr to manage the resource.
In this case, however, no dynamic allocation is necessary, simply have the SoftwareSerial object as a member variable:
Inheritance is not appropriate here, because there is no is-a relationship: a class that uses a serial port for communication is not itself a serial port.
Is the answer not already given in post #13 and #14? The first suggestion in post #13 is almost equivalent to the one you are using now, except it has an extra variable (var) as an example.