To create my own queue class, I need to declare a class attribute inside a function of this class.
What I am trying to do is :
when I call the function add
, the program creates a new attribute to the class, in private, to access after with the operator []
. By this I can create a queue without type restriction, using items of any class.
Is it possible?
Edit
This queue is just a use sample. My really question is: in python i can do this:
class Car:
def __init__ (self, ...):
...
self.color = 'blue'
Now, color can be used in anywhere of class (remember that don't need insert type to declare a variable in python. In the exemple, color was been declared in __init__
scope, but is a class atribute, and not a local variable).
How I can do something like this in c++?